JavaScript - Adding Javascript Into Iframe
hi,
Guys can u help me currently iam running clicksor ads on my blog but its decrease page load time and page stuck where javascrip is located can u help me . how can i put this javascript in iframe so that this javascript loads but never stuck the page thanx Regards Fawad Similar TutorialsAlright so I've been teaching myself php/javascript/html/joomla for the past couple weeks, learning as i go along. So bear with me if i seem like a total moron =p. I'm trying to run a script from a js file to add javascript to the website inside the iframe. I also would like the script to only be activated onclick(this is all in an article). To clarify my website has an iframe and this iframe contains a webpage from http://website987.com/. I want to run thescript.js on the website inside that iframe, to add javascript to that website, however i also only want to run this js file on the click of a link/button. I hope i'm being clear if I'm not please tell me and ill try to reiterate. I've been trying to get this to work for a while now and I feel like this is really simple and I'm asking a stupid question. However this is what I've got so far, currently this just redirects the iframe to the URL with my code on it(instead of actually running it).How could i edit this/what coding could I use to make it so thescript.js actually runs instead of it being just redirected? Reply With Quote Code: <?php $filename = 'thescript.js'; $path = '/media/system/js/'; // add the path parameter if the path is different than : 'media/system/js/' JHTML::script($filename, $path, true); // MooTools will load if it is not already loaded ?> Code: <HTML> <HEAD> <script language="javascript"> function loadOne() { parent.FRAME1.location.javascript: function('/media/system/js/thescript.js') } </script> </HEAD> <BODY> <iframe name="FRAME1" src="http://website987.com/" width="740" height="500" frameborder="0" scrolling="yes"></iframe> <a href="javascript:loadOne()">Click Here/a> </BODY> </HTML> Am i even on the right track? I've been testing out a billion different codes and I think it would be ridiculous to post them all so I was hoping someone could help me fix this code or at least point me in the right direction. I'm usually able to figure everything out on my own but I'm failing atm and I just need help on this one thing, I would be ever so thankful for any assistance provided, ! (BTW I'm also currently using the Joomla CMS and a joomla plugin called CodeMirror that runs your code directly from the article, not sure if this is relevent or not) I have a script which opens an HTML page and passes the current URL to a form on the page. I'm also using RokBox, which open a window as an overlay on the current page rather than as a popup. It is triggered by adding rel="rokbox" to any link. For instance, the following link opens moreinfo.htm using RokBox: Code: <a rel="rokbox" href="/modules/mod_S5tellafriend/moreinfo.htm">More Info</a> Problem is the link doesn't pass the URL. The following code passes the URL but doesn't trigger RokBox: Code: <input type="button" class="button" value="MORE INFORMATION" onclick="s5_open_taf_popup()"/> <script type="text/javascript"> var s5_taf_parent = window.location; function s5_open_taf_popup() { window.open('/modules/mod_S5tellafriend/moreinfo.htm','page','toolbar=0,scrollbars=1,location=0,statusbar=0,menubar=0,resizable=0,width=420,height=570,left=50,top=50,titlebar=yes') } </script> Is there a way to add rel="rokbox" to the script? Or maybe pass the URL with the link instead? Thanks! Hello - I need help adding the src in iframe tags. the problem to resolve looks like this: <script type="text/javascript"> /* Display the daily schedule in an inline frame. Daily schedules are stored in the files sunday.htm through saturday.htm. */ document.write("<iframe src ='weekday.htm'></iframe>") </script> Instructions say where weekday is the text string returned by the weekDay() function. I do have weekDay() function but I don't know how to include it into the iframe. I have a parent web page that uses a include file 'leftbar.html' as the left navigation. The parent page has a iframe and here is the code: Code: <iframe src="google.com" style="width: 100%; height: 500px" scrolling="yes" marginwidth="0" marginheight="0" frameborder="0" vspace="0" hspace="0"></iframe> Here is the code for each naviagation link on the left nav bar: Code: <tr> <td id="tdIndex" onmouseout="javascript:DoMouseOut(this)" onmouseover="javascript:DoMouseOver(this)" class="menuDefault" onclick="javascript:NavPage('All_Rooms_Today.html');">All Rooms Overview</td></tr> I want the onclick="javascript:NavPage to change the iframe which is currently google.com to a specific page. in this example it would all_rooms_today.html. So I need to write the javascript function Navpage that fills the iframe named internal. Thanks Hello, If JavaScript is disabled, does the content in an iframe become un-viewable/ blocked? This is in general, regardless of how safe or trusted the website/ content is. Code: <html> <head> <noscript>Javascript is disabled. Having it enabled provides the greatest functionality.</noscript> </head> <body> <noscript>Javascript is disabled. Having it enabled provides the greatest functionality.</noscript> <iframe src="first.html" width="300" height="300" /> </body> </html> Hello I'm having a little trouble. So far I've been able to achieve that when the user clicks on a button, they're be redirected to a random url. (this is from a list of different urls) I can't get it to work so when the user clicks on the button, they're be directed to the url through an iframe and not just loading a new page. I'm awful at explaining things so I donno if you's will understand me! index.html Code: <form name="myForm" id="myForm"> <p> <input type="button" name="myButton" value="url" onclick="rand_link()" /> ................ <iframe id="frame" src="iframe.html" width="100%" frameborder="0" marginheight="0" marginwidth="0"></iframe> ........ url.js Code: function go_to(url) { window.location=url; } function rand_link() { var a; a = 1+Math.round(Math.random()*2); if (a==1) go_to("http://google.com"); if (a==2) go_to("http://ask.com"); } Thanks! I have found a code to help me learn how to add forms in javascript, but it's limited to text input forms. Code: <script type="text/javascript"><!-- function updatesum() { document.form.sum.value = (document.form.sum1.value -0) + (document.form.sum2.value -0); } //--></script> Where the inputs sum1 and sum2 are text fields you put whatever numbers you want in. That works fine. Great. Now what I'm having trouble with is modifying the code so that it will add one form with an input number with a form that spits out a randomly generated number. Code: <input type="button" value="D20" onclick="this.form.display.value = Math.round (20 * Math.random())" class="buttonHi" /> <input name="display" type="text" size="6" value="" /> This is what I'm using for my random number generator. So basically I want to be able to put, say, 5, into the input text field above this. And then click on the d20 button to get a random number, say, 15, and then have the first code add the inputted 5 with the randomly generated 15. Is this possible? I have a simple problem. I want to add the current page's url to a link, like this: <code> <a href="http://www.somesite.com/somepage.aspx?a="> </code> After the 'a=' I need to add javascript that will return the current url. It can be the full url (example: http://www.codingforums.com/newthrea...=newthread&f=2) or a partial one (example: /newthread.php?do=newthread&f=2). Can someone help me with an example? I am trying to set up a web that new times will be displayed when they add current times to a form. here is the static HTML <form method="POST" > current time is 11:32 AM</p> <p>add <input type="text" name="T1" size="5" value="20"> mins and the new time time would be <b> 11:52 AM</b></p> <p>add another<input type="text" name="T2" size="5" value="15"> mins and the time then changes to <b>12:07 PM</b></p> <p><input type="submit" value="Submit" name="B1"></p> <p><input type="reset" value="Reset" name="B2"></p> </form> I would like to have the new times to change dynamically as they type in either (or both) input boxes How can I build a table that prompts user for number of rows and then number of columns and then builds it based on user input?
Hi, new to the forum (and Javascript coding). I hope someone can help as this is driving me nuts... I want my website to display the content of another webpage in an iframe. the other webpage extension will change each day (e.g. 'www.example.com/16_02_2012.html' would be today's file to view, 'www.example.com/15_02_2012.html' would have been yesterday's etc.). I have worked out some code to grab today's date and create the web address as a variable. how do i then use that variable in the <iframe src="??"> when someone click a link to "update the iframe"? Here is my code so far... I would really appreciate some help!!! :s <html> <script> function getMonth() { var now = new Date(); var month = now.getMonth(); return month < 10 ? "0" + (month+1) : month+1; } function getDay() { var now = new Date(); var day = now.getDate(); return day < 10 ? "0" + (day) : day; } var month = getMonth(); var day = getDay(); var year=new Date(); var address = "http://www.example.com/" + day + "_" + month + "_" + year.getFullYear() + ".html"; function iFrameWrite(id, url){ document.getElementById(id).src = url; } </script> <iframe id="info" width="800px" height="800px"></iframe><br /> <a href="#" onclick="javascript:iFrameWrite('info', 'address')">Update the Iframe</a> </html> I am having trouble with javascript code that is inside an iframe. I am trying to simulate the w3School's tryit. I have tried setting the content of the iframe two different ways and got two different results. This is example code for what I want the iframe's content to be <html> <head> <script type="text/javascript"> function coordinates(event) { x=event.screenX; y=event.screenY; alert("X=" x " Y=" y); } </script> </head> <body onmousedown="coordinates(event)"> <p> Click somewhere in the document. An alert box will alert the x and y coordinates of the cursor, relative to the screen. </p> </body> </html> The first way which was successful (but not what i want) is to save the example code as example.html and set the src property of the iframe to that document. Everything works fine including the mouseEvent. The second way displays the example.html in the iframe as it should but it seems to be ignoring the javascript. This is how I set the iframe content: I have the code stored in a database table. I use xmlHTTPRequest to bring grab the code and it is stored in a variable called responseText. Frome here I the following code sets the iframe content. r = document.getElementById("iframe"); Doc = r.contentWindow || r.contentDocument; if(Doc.document){ Doc = Doc.document; Doc.open(); Doc.write(responseText); Doc.close(); alert(Doc.documentElement.innerHTML); } If anyone can can help me understand why the javascript code doesn't work the second way I would greatly appreciate it. Hello Coding Forums, For the past few days, i have been learning and just surfing the forum board. I have recently ran into a problem and i am in need of help. This is a mixture of HTMl, XML, and JavaScript. For what i know, it seems my problem is a JS problem. I have been looking at this Facebook Fan page: http://www.facebook.com/pages/The-fi...18916928166010 I understand everything in the second page. The problem is i dont understand how in page 1, you are direct to page 2. Can anyone please explain to me how this is working? I am new with javaScript. Trust me, i have looked and i am still learning. This is important to me. -Mygel I am trying to run javascript within Iframe and its not running. (The bigger pictu The final target is to do a file upload without refreshing the page, and the original code is using the iframe as the target of the form, and the return from the server is a javascript code that should update some status field on the page. However the code return from the server is not running, so I just paste it in the iframe and it is still not running. ) Code: Content-type: text/html\n\n <html> <script type="text/javascript"> alert("this is running") </script> <iframe id="upload_target" name="upload_target" src="#" style="width:100;height:100;border:0px solid #fff;"> <script type="text/javascript"> alert("this not running") </script> </iframe> </html> Hello, I would like to know which statement I should use in order to echo an iframe in JS. Thanks, Ben Hello all i am working on a project. i would like to know how to remove the scroll bars , and how to align the captcha/webpage that loads in the iframe. <title>Test Raid Page</title> <script language="JavaScript" type="text/javascript"> <!--Begining of Java Script- function buildiframesA() { var rlink = prompt('Enter Raid ID:',""); var a = document.createElement("iframe"); a.setAttribute("width","330"); a.setAttribute("scrolling=no"); a.setAttribute('******', 'ifrm1'); document.body.appendChild(a); a.setAttribute('src', "http://*****.******/joinraid.php?raidid=" + rlink + "&suid=******&serverid=2"); } </script> Anything with "************" has been removed due to privacy i added this code in a.setAttribute("scrolling=no"); and it disables the whole script but, in dreamweaver shows it is fine, when i load to debug and click group a to load the frame nothing happens, ive tried many ways to disable the scroll bars and cant figure a way out. There is more to the script this is just my test for the iframe, what i have is groups, all accounts are grouped in groups, when a group is clicked, i am prompt with Enter raid ID, i enter the raid ID and the frames for how ever many people in that group load, on those pages that load in the iframe is a raid page with a captcha to join the raid, the captcha shows automatically in the frame but it is not perfectly aligned as i want it to be. I use dreamweaver and can debug in my browser, any help is appericiated, i can also post pictures as to what i am talking about. EDIT: i also forgot to say i am new to javascript, i know html and php very well.. MrGato =D Hi, im fairly new at all this, so please forgive me if I have misunderstood the guidelines on posting threads for this topic. Im needing some help with adding a timed delay for a widget I have on my website. My website is hosted on moonfruit, a flash based web builder, its very beginners level, and so this makes me feel like the new kid at school posting on this forum. however moonfruit does have a HTML/JavaScript snippet Which allows me to paste in code and show the cooliris gallery But is has become crucial to my websites completion that this widget must have a timed delay on it ive been at google for days till the point where im seeing the same pages again, and have come across setTimeout, unfortunately that's as far as I can seem to go, ive tried pasting in the code in numerous places and I just cant get it to work, i have pasted in other JavaScript codes, and they have worked, so i am convinced that its just me being a noob, other than it being a limitation on moonfruit I would appreciate any help with this Here is the code that im trying to get a delayed time of 10 seconds or so. [CODE] <object id="o" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="845" height="350"><param name="movie" value="http://apps.cooliris.com/embed/cooliris.swf"/><param name="allowFullScreen" value="true" /><param name="allowScriptAccess" value="always"/><param name="flashvars" value="style=dark&backgroundColor=#0d0d0d&feed=api://www.flickr.com/?user=41683862@N04%26album=72157622009594203&glowColor=#FFFFFF&showSearch=false&showEmbed=false&show Tutorial=true&showChrome=true"/><embed type="application/x-shockwave-flash" src="http://apps.cooliris.com/embed/cooliris.swf" flashvars="style=dark&backgroundColor=#0d0d0d&feed=api://www.flickr.com/?user=41683862@N04%26album=72157622009594203&glowColor=#FFFFFF&showSearch=false&showEmbed=false&show Tutorial=true&showChrome=true" width="845" height="350" allowFullScreen="true" allowScriptAccess="always"></embed></object> [CODE] Again any help is most appreciated My code goes through the answer function (below) and it determins if you answered green. If you answered green a popup says correct other wise incorrect. How can I modify my code so that I can add multiple answers for different questions.Example q1 answer = green q2 answer = blue . . q20 answer = Friday Here is my .js code Code: var n = 16; // modify this for number of seconds to answer document.getElementById( 'time').value = "Answer in " + n + " seconds"; var i = setInterval('count()' , 1000); var tooLate; function count() { tooLate = 0; n--; if(n >=0) { document.getElementById( 'time').value = "Answer in " + n + " seconds"; } else { clearInterval(i); alert("Too late!"); if(document.getElementById( 'answer').value == correct){ tooLate = 1; } } function answer() { var correct = "green"; // This is the correct answer if (tooLate == 0) { if(document.getElementById( 'answer').value == correct) { clearInterval(i); alert("Right Answer with " + n + " seconds remaining"); } else{ clearInterval(i); alert("Incorrect! The answer was " + correct); } } submitform(); //submit form function submitform() { document.forms["myform"].submit(); } } Hey all, I'm sure this is very basic but I'm having a hard time adding a hyperlink to text within javascript. I want to add a website link to the text 'click here' that is being displayed under the image within javascipt. I end up modifying the whole image instead, removing the javascript that displays the larger version of the image. Can anyone help me out please? Here's the coding. I'm using Dreamweaver CS5 on a PC to modify a few things and using another website building program to get the basic layout. I'm just a small business owner trying to get my website off the ground. Thanks in advance! <div id="imCel1_01"> <div id="imCel1_01_Cont"> <div id="imObj1_01"> <a href="javascript:imShowBox('files/june2011.jpg',500,500,'Right click to print....................Click HERE for website!','IMG','t');" title=""><img src="images/p025_1_01.jpg" alt="" title="" /></a> </div> Hello all! I am using 'simplecartjs' as a simple shopping cart for my website. To checkout, the user e-mails me his cart containts. I would like to have his name, email and adress with this but i'm unable to add this to my shopping form. Here is my JS: Code: me.emailCheckout = function() { itemsString = ""; for( var current in me.items ){ var item = me.items[current]; itemsString += item.name + " " + item.quantity + " " + item.price + "\n"; } var form = document.createElement("form"); simpleCart.empty(); form.style.display = "none"; form.method = "POST"; form.action = "sendjs.php"; form.acceptCharset = "utf-8"; form.appendChild(me.createHiddenElement("jcitems", itemsString)); form.appendChild(me.createHiddenElement("jctotal", me.total)); document.body.appendChild(form); form.submit(); document.body.removeChild(form); } And here is the PHP that sends is (sendjs.php): Code: <?php $to = 'info@kheuning.nl'; $subject = 'the subject'; $jcitems = $_POST['jcitems']; $headers = 'From: webmaster@example.com' . "\r\n" . 'Reply-To: webmaster@example.com' . "\r\n" . 'X-Mailer: PHP/' . phpversion(); mail($to, $subject, $jcitems, $headers); Header('Location: thankyou.html'); ?> I understand how to add variables to send in my php form, but it doesn't take normale html form input's i add to the page. How can i add these to the js? Thanks in advance! Jonas |