Jump to content

JS Variable Passing Help :(


kareem_elzeiny

Recommended Posts

Hello guys,I'm totally new in this field and I was reading about how yo make Variable Passing using JavaScript an I can't change it to the way that I need !!The Tutorial SourceWell,, the situation here is that I have two sites "Site1" & "Site2"At "Site1" the the visitor will Click a link like that

http://www.Site2.com/?Link=download.net/example.zip

Then at "Site2" there should be a Script that counts down from 10 to 1After that a Button should appear and when clicked should open the link "download.net/example.zip" in new windowThe Script that I'm using in "Site2" is

<center><span id="waiting_getlink"> </span><form name="joe"><input type="hidden" name="burns" /></form><script language="javascript">var locate = window.locationdocument.joe.burns.value = locatevar link = document.joe.burns.valuefunction delineate(str){theleft = str.indexOf("=") + 1;theright = str.lastIndexOf("&");return(str.substring(theleft, theright));}function getlink(secs){			secs--;			if(secs>0){				document.getElementById("waiting_getlink").innerHTML = 'Click Here  ' + secs				window.setTimeout("getlink("+secs+");",1000);			} else {				document.getElementById("waiting_getlink").innerHTML =  delineate(link);		 			}		}getlink(10);</script></center>

But this Only Will Show the link "download.net/example.zip" and it's not Clickable I Can't Modify it to show a Button and when clicked should open the link "download.net/example.zip" in new windowOnly using Java Script and HTML without Cookies any Help will be appreciated ,,Regards,

Link to comment
Share on other sites

On the second page, why not just have a initially hidden (w/CSS) button appear after the countdown? It would also be possible to use the variable passed to be used in an on click handler for that button element to execute a function to initiate the pop-up functionality.

Link to comment
Share on other sites

do you know CSS? Look up how to use CSS to hide an element. By giving it display: none it will be hidden when the page loads. Then, when your counter counts down, you can use javascript to change it's display (to show it). Get that working and then we can move onto the onClick handler. Just take it in steps, one piece of functionality at a time.

Link to comment
Share on other sites

Ok The Button Code would be like that

<input type="BUTTON" id="DButton" value="Click Here to Download"  style="display: none;" />

and this should be the JS code to make it visible

document.ElementById("DButton).style.visibility = "visible";

But When I add it to the counter it doesn't work

<span id="waiting_getlink"> </span><form name="joe"><input type="hidden" name="burns" /></form><script language="javascript">var locate = window.locationdocument.joe.burns.value = locatevar link = document.joe.burns.valuefunction delineate(str){theleft = str.indexOf("=") + 1;theright = str.lastIndexOf("&");return(str.substring(theleft, theright));}function getlink(secs){			secs--;			if(secs>0){				document.getElementById("waiting_getlink").innerHTML = 'Click Here  ' + secs				window.setTimeout("getlink("+secs+");",1000);			} else {								document.ElementById("DButton).style.visibility = "visible";		 			}		}getlink(10);</script>

So what goes wrong here ??

Link to comment
Share on other sites

http://www.google.com/#hl=en&sugexp=ld...fd6907b8cfcbc76edit: it can also be done using target with HTML, but it won't pass Strict validation. XHMTL and/or HTML
You can add target="blank" with JavaScript, which is perfectly vaild/no HTML validation errors or use the HTML doctype in which it is perfectly valid practice to use target="blank"
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...