JavaScript - Can I Copy Text Content From <iframe> To Variable ?
Hi world
I have this code in my page PHP Code: <iframe name="ff1" src="http://playerplus.co.nu/ipp.php" ></iframe> how i copy the result in this iframe to text or to some variable but from iframe not direct from the URL "http://playerplus.co.nu/ipp.php" Similar TutorialsHello. I have a textarea where user can select a text then copy to clipboard (using EditArea script for highlighting) I need append additional information to the selected text so it won't be visible in the textarea, but only appear after copied to clipboard. For example: Code: text line one text line two text line three user selected word "two", hit CTRL+C to copy into clipboard (or used browser's context menu), but in clipboard it should be saved as: "selected word 'two'" What would be the approach? Thank you. I have been looking all over google and i cant find it. How would you make a text box and when you type in it it would display the words underneath?
I know how to make something function onclick(), but how can I make it so it copies the area of a textarea element, does Javascript have the ability to do this? Thanks for any help in advance. Hello, I've been looking around the web for a simple JavaScript to solve this problem but can't seem to find something that would work both in IE and FF and the other major browsers? So basically I have a page listing about a dozen badges people can use to link back to me. I have presented the code for each badge (eg. a href, img src, alt...) in a separate textarea and I'd really love to add a link next to each textarea that would say something like "Click here to copy to Clipboard" then it would copy the text from within the corresponding textarea to the Clipboard so as to eliminate the need for Ctrl+A, Ctrl+C. Thank you in advance people! I have a small snippet of code which will copy the contents of a textbox to the clipboard when a small image, say a button, is clicked. I want to achieve a similar effect when I click a hotspot on an image, but in this case the text will have to come from...well, I don't know. Maybe the title in an area tag? This is what I have so far for a textbox: Code: //clipboard copy function ClipBoard(what){ Copied = document.getElementById(what).createTextRange(); Copied.execCommand("Copy"); alert ("Information copied to the clipboard. Use CTRL-V to paste."); } <textarea id="holdtext1"></textarea> <img border="0" src="copyclick.gif" onclick="ClipBoard('holdtext1');" alt=" Click to copy text to clipboard / CTRL-V to paste" style="cursor: hand" width="18" height="18"> Does anyone have any ideas? Hi Friends, I need a copy to clipboard functionality from a text area using javascript. I use Zclip for the purpose, but it will not work as needed . I attach my working code along with this .. pls open index.html in browser and try it . Do any one can pls give a javascript solution to copy textarea content to clipboard... Thanks, Anes What wrong in this code? Code: <script type="text/javascript" src="jquery.js"></script> <script> $(function (){ function manda(){ var text = $('#frame').contents().find('p[class=no_boder]').html(); $('div').html(text); } }); </script> i've already tried using this -> $('#frame').contents().html(); How can i get the content? Hi all, I have: Code: var moreinfo =""; moreinfo+= "here some content"; $("#divMoreInfo").html(moreinfo); And this inserts "here some content" in a div called divMoreInfo. Now divMoreInfo is placed inside an iframe while the rest of the programming has to be in the parent page... How do I insert moreinfo's contents in the iframe's div?? Thanks a lot Good Day Everyone, I need some help resizing an iframe to fit it's content. Basically, I have 10 spreadsheet pages saved as htm files. I am creating a page that enables me to view each of these htm files. I need the iframe to be resized for each htm file. This is my code: Code: <html> <head> <script language="javascript"> <!-- var state = 'none'; function showhide(layer_ref) { if (state == 'block') { state = 'none'; } else { state = 'block'; } if (document.all) { //IS IE 4 or 5 (or 6 beta) eval( "document.all." + layer_ref + ".style.display = state"); } if (document.layers) { //IS NETSCAPE 4 or below document.layers[layer_ref].display = state; } if (document.getElementById &&!document.all) { hza = document.getElementById(layer_ref); hza.style.display = state; } } function autoResize(id) { var winW = 0, winH = 0 ; if (document.body && document.body.offsetWidth) { winW = document.body.offsetWidth - 235; winH = document.getElementById('page').contentWindow.document.body.scrollHeight; } document.getElementById(id).height=(winH) + "px"; document.getElementById(id).width=(winW) + "px"; } //--> </script> <style type="text/css"> .yssOver{background-color:#ffffff;} .yssOut{ background-color:#E6EFFF;} #content { position:absolute; left:210px; top:40px; } html { overflow:off; } img { display:block; vertical-align:text-top;} h1{ color: #000000; font-family:"Arial",Times,sans-serif; font-weight:bold; font-size:12px; margin-bottom:0px; } #document{ position:absolute; top:0px; left:0px; } #menu{ margin: 0 0 0 0; padding-left:0px; border: 0 -10 0 0; } img.arrow { margin: 4 0 0 0; } table.menu td { border: 1px solid; border-color:#7D91D0; } table.div td { border: 0px solid; border-color:#7D91D0; } a:link {color: #000000; font-family:"Arial",Times,sans-serif; font-size:12px; text-decoration: none;} a:active {color: #000000; font-family:"Arial",Times,sans-serif; font-weight:bold; font-size:12px;} a:visited {color: #000000; font-family:"Arial",Times,sans-serif; text-decoration: none; font-size:12px;} a:hover {color: #000000; font-family:"Arial",Times,sans-serif; font-size:12px;} </style> </head> <body onLoad = "window.frames['page'].location = 'home.png'" > <table id=document border=0 cellpadding=0 cellspacing=0> <tr><td> <img src=halifax_logo.png></img> </td><td width=100%> <img src=headerback.png width=100% height=80></img> </td></tr> <tr><td> <table width=95% class=menu border=1 id=menu border=0 cellpadding=0 cellspacing=5 background=menuback.png> <tr><td> </td></tr> <tr><td class=menutd background=tdback.png> <a href="cofunds designations.htm" target="page"> Cofunds Designations</a> </td></tr> <tr><td class=menutd background=tdback.png> <a href="Commission Codes Most Used.htm" target="page" " height=516 width=974 onmousedown="if(document.getElementById('div2').style.display == 'none'){ document.getElementById('div2').style.display = 'block'; }else{ document.getElementById('div2').style.display = 'none'; }"> Commission Codes</a> <div id="div2" style="display: none;"> <table class=div border=0 cellpadding=0 cellspacing=0 style=background-color:#E6EFFF; border: 1px solid; border-color:#7D91D0; width=100%> <tr><td> <img class=arrow src=side_grey_arrow.png></img> </td><td class="yssOut" onmouseover="className='yssOver';" onmouseout="className='yssOut';"> <a href="Commission Codes Most Used.htm" target="page">Most Used</a> </td></tr> <tr><td valign=top> <img class=arrow src=side_grey_arrow.png></img> </td><td class="yssOut" onmouseover="className='yssOver';" onmouseout="className='yssOut';"> <a href="Commission Codes.htm" target="page">All</a> </td></tr> </table> </div> </td></tr> <tr><td class=menutd background=tdback.png> <a href="corporate accounts1.htm" target="page"> Corporate Accounts</a> <div id="div3" style="display: none;"> <table class=div border=0 cellpadding=0 cellspacing=0 style=background-color:#E6EFFF; border: 1px solid; border-color:#7D91D0; width=100%> <tr><td> <img class=arrow src=side_grey_arrow.png></img> </td><td class="yssOut" onmouseover="className='yssOver';" onmouseout="className='yssOut';"> <a href="research.png" target="page">Research Centre</a> </td></tr> <tr><td valign=top> <img class=arrow src=side_grey_arrow.png></img> </td><td class="yssOut" onmouseover="className='yssOver';" onmouseout="className='yssOut';"> <a href="reports.png" target="page">Company Reports</a> </td></tr> </table> </div> <tr><td class=menutd background=tdback.png> <a href="dealers.htm" target="page"> Dealers</a> </td></tr> <tr><td class=menutd background=tdback.png> <a href="halifax funds.htm" target="page"> Halifax Fund Managers</a> </td></tr> <tr><td class=menutd background=tdback.png> <a href="other fund managers.htm" target="page"> Other Fund Managers</a> </td></tr> <tr><td class=menutd background=tdback.png> <a href="international codes.htm" target="page"> International Codes</a> </td></tr> <tr><td class=menutd background=tdback.png> <a href="market makers1.htm" target="page"> Market Makers</a> </td></tr> <tr><td height=750> </table> </td><td> <div id=content> <IFRAME name=page src="cofunds designations halifax.htm" onLoad="autoResize('page');" frameborder=0 overflow=no marginwidth=0 marginheight=0></iframe> </div> </td></tr> </table> </body> </html> This seems to work but it has a few issues, It does not resize properly for every link, only some of them. Can somebody please have a look & tell me where I am going wrong, or provide me with some better code, mine is a bit shoddy! Thanks Harry hi all, I really need help with this topic. I have to use onMouseOver to change the content of an iframe. I'm trying to use an array but I'm confused and I'm not really sure if what I'm doing is correct and it doesnt work. I will appreciate your help and understanding. Thanks a lot! here is part of my code.. var frame=new Array(6); frame[0]="page1.html"; frame[1]="page2.html"; frame[2]="page3.html"; frame[3]="page4.html"; frame[4]="page5.html"; frame[5]="page6.html"; var j=0; function nextFrame() { if (j < 5) { j++; document.getElementById(frame).contentDocument=frame[j]; } return; } <span onMouseOver="nextFrame()" > <img name="upperImage" src="something.jpg" width=350 height=250 /></span> <iframe id="frame1" name="frame1" src="" width=350 height=250 frameborder="0"> </iframe> Please let me know if at least I'm in the right track. Thanks Hi all, I want to write i frame content to PDF file.Can any one help me how to do it In my page, I have a main iframe where I want all the content of my links to be loaded. I want the iframe's height to resize according to the content. All the linked pages are in the same domain. I have tried some scripts I found, but nothing has the result I want. The HTML code is: Code: <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>index</title> <link href="styles.css" rel="stylesheet" type="text/css" /> </head> <body> <div id="container"> <div id="header"></div> <div id="nav"> <a href="home.html" target="frame">Home</a> <a href="the_band.html" target="frame">The Band</a> <a href="News.html" target="frame">News</a> <a href="gallery.html" target="frame">Gallery</a> <a href="contact.html" target="frame">Contact</a> </div> <iframe id="frame"></iframe> <div id="footer"></div> </div> </body> </html> The CSS code is: Code: div#container { height: 100%; width: 100%; } div#header { top: 0px; width: 100%; height: 80px; position: fixed; background-color: transparent; text-align: center; } div#nav { font-family: MgSouvenirLight; font-size: 18pt; color: #FF0; top: 120px; width: 100%; height: 40px; position: fixed; text-decoration: none; font-weight: bolder; font-variant: normal; } div#footer { font-family: Arial, Helvetica, sans-serif; font-size: 9px; bottom: 0px; position: fixed; height: 30px; width: 100%; text-align: center; color: #fff; } #frame { position: absolute; top: 200px; bottom: 40px; width: 800px; border: none; left: 120px; height: auto; } a:link { font-family: MgSouvenirLight; font-size: 18pt; color: #FF0; } a:visited { font-family: MgSouvenirLight; font-size: 18pt; color: #FF0; } a:hover { font-family: MgSouvenirLight; font-size: 18pt; font-style: italic; color: #FC0; } I don't know how to make scripts on my own, so I would appreciate any help. Thank you! Ok, I paid to have a website built, yet the developer used iFrames to accomplish the task. Basically, load a parent page, and then in an iframe, lod content chosen from a menu. Is there a way to create a menu at the homepage level, that will allow a menu listing the various parent pages, and under each parent page, have a drop down that will point directly at an iframe content? Like this? Page1 Page2 Page3 Page1ContentA Page1ContentB Page1ContentC And when you click Page1ContentC, it will load Page1.htm and in the iframe load Page1ContentC? If i am not clear, please let me know. Any help appreciated. Jeff The project I am working on involves a flash piece that communicates with a iframe. Currently the flash piece just calls on javascript functions. I want the buttons in the flash piece to be able to change the src of the iframe. PHP Code: <script type="text/javascript"> document.getElementById('video').setAttribute('src',address2); function closeVideo() { document.getElementById('video').style.height='0px'; return false; document.getElementById('video').setAttribute('src', address2); } function openVideo() { document.getElementById('video').style.height='391px'; return false; document.getElementById('video').setAttribute('src', address); } </script> So the way the code works now is when the page loads it sets the iframe with the id of 'video' to the variable address2 which it pulls from an XML file. In the flash piece when a button is hit, it calls openVideo() which "opens" the iframe and I want it to change the contents to address. This does not work though. It opens the frame but will not change the src. I've tried a bunch of different things now such as make the flash target the iframe using navigateToURL(request1, 'video'); but in Firefox and IE is opens it stills as if I had _blank in there. It does strangely work in Safari. Any ideas how to get this to work? I'm new to javascript so it could be something basic I'm overlooking 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> Ok, I am aware this will sound like a plug for my script, but please bare with me. I created a bookmarklet script to help me audit extremely large style sheets. Basically while on a site that you would like to audit, you click the bookmarklet and the document's body contents gets remove and replaced with an iframe that points to the current sites home page. From here you can choose what style sheet (the script finds) to begin reporting over. The more pages you browse (through the iframe) the more accurate the report gets. My problem however, is if the person is on the site's home page when first running the script, the iframe never loads up. I think it has to do with the fact that you are on the home page, and then the iframe tries to point to the home page as well and fails for some reason. Is there any solution that comes to mind for anyone out there? You can test it by bookmarking this bookmarklet and running it on any site's home page where style sheets can be found: Get The Bookmarklet on this page Again, it works great if you don't start the script from a sites home page. It's a well documented issue- when you have a page that contains an iframe, and then navigate inside the iframe, hitting the browsers back button will only affect the contents of the iframe and not the entire page. I've been searching all over for solutions and cant find one that works for my current implementation. Anyone have any suggestions? Here is my code: js Code: function ShowPage(frame) { frames[0].location = frame+'.html' frame.contentWindow.location.replace(newUrl); } Buttons that change the contents of the iframe Code: <div id="thumb1"><a onmouseover="ShowPage('frame1')"onclick="ShowPage('frame1')" rel="nofollow" target="mainbox"></a></div> <div id="thumb2"><a onmouseover="ShowPage('frame2')"onclick="ShowPage('frame2')" rel="nofollow" target="mainbox"></a></div> <div id="thumb3"><a onmouseover="ShowPage('frame3')"onclick="ShowPage('frame3')" rel="nofollow" target="mainbox"></a></div> and then the iframe itself Code: <iframe src="frame1.html" type="text/html" style="border-width:0; border-style:hidden;" transparency="true" name="mainbox" frameborder="0" scrolling="no" width="700" height="807"> </iframe> |