kareem_elzeiny Posted May 11, 2011 Share Posted May 11, 2011 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 More sharing options...
thescientist Posted May 11, 2011 Share Posted May 11, 2011 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 More sharing options...
kareem_elzeiny Posted May 11, 2011 Author Share Posted May 11, 2011 thank you for that ,, But I'm totally new to this .Can you help me with the code Please ?? Link to comment Share on other sites More sharing options...
thescientist Posted May 11, 2011 Share Posted May 11, 2011 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 More sharing options...
kareem_elzeiny Posted May 11, 2011 Author Share Posted May 11, 2011 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 More sharing options...
thescientist Posted May 11, 2011 Share Posted May 11, 2011 http://www.w3schools.com/css/pr_class_display.aspread that page, in particular the part about javascript syntax. Link to comment Share on other sites More sharing options...
kareem_elzeiny Posted May 11, 2011 Author Share Posted May 11, 2011 Thank you it worked ,, Now what about the variable passing Link to comment Share on other sites More sharing options...
thescientist Posted May 11, 2011 Share Posted May 11, 2011 http://www.w3schools.com/jsref/obj_location.asp Link to comment Share on other sites More sharing options...
kareem_elzeiny Posted May 11, 2011 Author Share Posted May 11, 2011 Thank you man It works really greatBut all the methods results in opening the link in the same page ,,Is there any way to open the link in new window ?? Link to comment Share on other sites More sharing options...
thescientist Posted May 11, 2011 Share Posted May 11, 2011 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 Link to comment Share on other sites More sharing options...
kareem_elzeiny Posted May 12, 2011 Author Share Posted May 12, 2011 Thanks Link to comment Share on other sites More sharing options...
roundcorners Posted May 16, 2011 Share Posted May 16, 2011 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 HTMLYou 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 More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.