Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Subscriber script not working in Safari

Status
Not open for further replies.

webBarney

Technical User
Sep 2, 2008
4
US
I've had a problem with the following script working in Safari web browsers. Works fine in all others but not Safari. Did I miss something??

<script language="javascript">
<!--
function CreateForm()
{
//create form
var form = document.createElement("Form");
form.action = " form.name = "ccoptin";
form.target = "_blank";
form.method = "post";
//create text field
var emailInput = document.createElement("Input");
emailInput.type = "text";
emailInput.name = "email";
emailInput.size = "75";
emailInput.value = window.document.Form2.elements["LeftColumnNav1_tbEmail"].value
//create submit button
var submitBtn = document.createElement("Input");
submitBtn.type = "submit";
submitBtn.name = "go";
submitBtn.value = "GO";
//create hidden inputs
var hidden1 = document.createElement("Input");
hidden1.type = "hidden";
hidden1.name = "list";
hidden1.value = "newsletter";
var hidden2 = document.createElement("Input");
hidden2.type = "hidden";
hidden2.name = "confirm";
hidden2.value = "one";
var hidden3 = document.createElement("Input");
hidden3.type = "hidden";
hidden3.name = "showconfirm";
hidden3.value = "F";
var hidden4 = document.createElement("Input");
hidden4.type = "hidden";
hidden4.name = "url";
hidden4.value = "
form.appendChild(emailInput);
form.appendChild(submitBtn);
form.appendChild(hidden1);
form.appendChild(hidden2);
form.appendChild(hidden3);
form.appendChild(hidden4);
window.document.appendChild(form);
form.submit();
}
//-->
</script>
<script language="JavaScript" type="text/javascript">
function clearDefaultText2(obj){
if (obj.value == "")
{
obj.value = "";
}
}
</script>

Any help would be appreciated...
 
This is invalid, AFAIK:

Code:
window.document.appendChild(form);

Works fine in all others

But not Firefox 2, where the error is pointed out.

Try using "document.body" instead, as you want to insert the form in the body, I'd have thought.

Hope this helps,
Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
thanks for replying Dan.
Not sure what you mean though. I'm new to this and the script war written for us by someone else. Make the change to the "(form)" or the preceeding line "window.document.appendChild"

I appreciate the help.
 
I see what you mean, just tried it in Firefox 2. The error I got from Firefox shows it hanging up on the "hidden4.name = "url";" line. Is that what you saw too?
 
No. All I needed to do was to change this:

Code:
window.document.appendChild(form);

to this:

Code:
document.body.appendChild(form);

Of course, the script assumes you also have a form present named 'form2' with an element named 'LeftColumnNav1_tbEmail'. If this isn't present, you'll get an error and so should comment that line out.

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
Thanks again Dan! That worked perfectly. I appreciate your help. I've been scratching my head on this for a couple of days now.

all the best,
Dave
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top