bw83 Posted September 13, 2008 Share Posted September 13, 2008 Ok so i have a script that works fine but it sucks to have to edit the url from notepad. So i was working on putting a popup promt box in there to make it easier but for some reason the box isnt openingthis is the original <html> <head> <script type="text/javascript"> var frame_url = "http://api.msappspace.com/proxy/relay.proxy?opensocial_authtype=SIGNED&opensocial_token=F68Nd0zvr5JhGuL3ajJAYPYTpcEAWrQ0hKETAa3gq7yKddBLXFYqB99mz3USuqV1D69AyNmTVUA9rrsP+WyoJjC02h4hJ8OQ6BlKHZop3ek=&opensocial_url=http%3A//mob-dynamic-lb5.mobsters08.com/mob/increase_attribute%3Fuser_id%3D402811394%26attribute%3Ddefense_strength%26session_id%3D1f7746117fe8fb0ab889931208fcb1750a6e99b2%26session_key%3D3bbacc6b42c315e8b5bc3c11a53fc2d97350046c"; function refresh_frame(frame_id, theurl) { var fr = document.getElementById(frame_id); var now = new Date(); now = now.valueOf(); fr.src = theurl + "&now=" + now; } setInterval('refresh_frame("Fight", frame_url);', 400); </script> </head> <body> <IFRAME id="Fight" width=800 height=200 marginwidth=0 marginheight=0 frameborder=0 scrolling=auto></IFRAME> <script type="text/javascript"> document.getElementById("Fight").src = frame_url; </script> </body></html> then this one is where i tried to replace the frame_url link with a prompt box to determine it <html> <head><script type="text/javascript">function disp_prompt(){var frame_url = prompt("Please enter your name","Harry Potter");if (name!=null && name!="")}</script> <script type="text/javascript"> var frame_url = ""; function refresh_frame(frame_id, theurl) { var fr = document.getElementById(frame_id); var now = new Date(); now = now.valueOf(); fr.src = theurl + "&now=" + now; } setInterval('refresh_frame("Fight", frame_url);', 400); </script> </head> <body> <input type="button" onclick="disp_prompt()" value="Display a prompt box" /> <IFRAME id="Fight" width=800 height=200 marginwidth=0 marginheight=0 frameborder=0 scrolling=auto></IFRAME> <script type="text/javascript"> document.getElementById("Fight").src = frame_url; </script> </body></html> any help is greatly appeciated Link to comment Share on other sites More sharing options...
bw83 Posted September 13, 2008 Author Share Posted September 13, 2008 and yea the harry potter thing was because i got it fromt he tutorial but since the box doesnt popup changing that hasnt occured to me yet Link to comment Share on other sites More sharing options...
jeffman Posted September 13, 2008 Share Posted September 13, 2008 There were so many problems with your original that just I rewrote everything. To explain the changes would be a basic course in javascript and HTML. With luck, you can study what I did and learn something. If you want to style your iframe, you should add a stylesheet and some CSS. Unless your fight page downloads very fast, you might reconsider that interval. 400 milliseconds isn't much time.FWIW, you weren't getting a prompt because you had an error in disp_prompt(). Your if statement was incomplete. <html> <head> <script type="text/javascript"> function refresh_frame(frame_id, theurl) { var fr = document.getElementById(frame_id); var now = new Date(); now = now.valueOf(); fr.src = "http://" + theurl + "?now=" + now; } var frame_url = ""; var interval; function disp_prompt() { frame_url = prompt("Please enter a URL: http://", frame_url); if (frame_url != ""){ interval = setInterval('refresh_frame("Fight", frame_url);', 400); } else { clearInterval (interval); } } function init () { document.getElementById("prompt_button").onclick = disp_prompt; } window.onload = init; </script> </head> <body> <input type="button" value="Get URL" id="prompt_button"> <iframe id="Fight"></iframe> </body></html> Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.