anf.etienne Posted February 24, 2009 Share Posted February 24, 2009 hi, ive got this piece of coding that generates a table with images and a link to edit the images. I need the links to redirect to a iframe on my page but when i add the code in to redirect it only shows that it is calling a javascript function rather than actually linking i.e. javascript:loaditFrame(iframeresize, <?php for($i=0; $i<5; $i++){ if($i != 0){ $start = $start + $max_items; $end = $end + $max_items; } echo "<td>"; for($x = $start; $x < $end; $x++){ $imageL= $path.$item[$x]; $img_path="http://ve-creative.com/test/8/$imageL"; // display the item echo '<center><p><img src= "'.$path.$item[$x] .'" height="100" width="100"></p></center>'; echo "<a href="'javascript:loadintoIframe(iframeresize, demo2_edit.php?img=$img_path)'">[Edit / resize]</a><br>"; } echo "</td>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/146678-target-iframe/ Share on other sites More sharing options...
DEVILofDARKNESS Posted February 24, 2009 Share Posted February 24, 2009 I don't see why your link is both double and single quotes? <a href="'javascript...'"> I would just use single quotes (because the echo already use doubles) <?php for($i=0; $i<5; $i++){ if($i != 0){ $start = $start + $max_items; $end = $end + $max_items; } echo "<td>"; for($x = $start; $x < $end; $x++){ $imageL= $path.$item[$x]; $img_path="http://ve-creative.com/test/8/$imageL"; // display the item echo '<center><p><img src= "'.$path.$item[$x] .'" height="100" width="100"></p></center>'; echo "<a href='javascript:loadintoIframe(iframeresize, demo2_edit.php?img=$img_path)'>[Edit / resize]</a><br>"; } echo "</td>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/146678-target-iframe/#findComment-770092 Share on other sites More sharing options...
anf.etienne Posted February 24, 2009 Author Share Posted February 24, 2009 i was just testing so many different things to see what works....thanks i will give that a shot Quote Link to comment https://forums.phpfreaks.com/topic/146678-target-iframe/#findComment-770140 Share on other sites More sharing options...
anf.etienne Posted February 24, 2009 Author Share Posted February 24, 2009 ok it shows the full link but i dont think that the php is recognising the javascript that is in the link.....is there anyway to get it to recognise the function so it calls the javascript this is the javascript im trying to call <script type="text/javascript"> //Input the IDs of the IFRAMES you wish to dynamically resize to match its content height: //Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none: var iframeids=["iframeresize"] //Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended): var iframehide="yes" var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1] var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers function resizeCaller() { var dyniframe=new Array() for (i=0; i<iframeids.length; i++){ if (document.getElementById) resizeIframe(iframeids[i]) //reveal iframe for lower end browsers? (see var above): if ((document.all || document.getElementById) && iframehide=="no"){ var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i]) tempobj.style.display="block" } } } function resizeIframe(frameid){ var currentfr=document.getElementById(frameid) if (currentfr && !window.opera){ currentfr.style.display="block" if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight; else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax currentfr.height = currentfr.Document.body.scrollHeight; if (currentfr.addEventListener) currentfr.addEventListener("load", readjustIframe, false) else if (currentfr.attachEvent){ currentfr.detachEvent("onload", readjustIframe) // Bug fix line currentfr.attachEvent("onload", readjustIframe) } } } function readjustIframe(loadevt) { var crossevt=(window.event)? event : loadevt var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement if (iframeroot) resizeIframe(iframeroot.id); } function loadintoIframe(iframeid, url){ if (document.getElementById) document.getElementById(iframeid).src=url } if (window.addEventListener) window.addEventListener("load", resizeCaller, false) else if (window.attachEvent) window.attachEvent("onload", resizeCaller) else window.onload=resizeCaller </script> Quote Link to comment https://forums.phpfreaks.com/topic/146678-target-iframe/#findComment-770169 Share on other sites More sharing options...
DEVILofDARKNESS Posted February 25, 2009 Share Posted February 25, 2009 I think it should be... <?php require_once 'javascript.js'; /* IF THE SCRIPT IS LOCATED IN JAVASCRIPT.JS ELSE DO IT WITH THE NEXT:*/ /* <script type="text/javascript"> //Input the IDs of the IFRAMES you wish to dynamically resize to match its content height: //Separate each ID with a comma. Examples: ["myframe1", "myframe2"] or ["myframe"] or [] for none: var iframeids=["iframeresize"] //Should script hide iframe from browsers that don't support this script (non IE5+/NS6+ browsers. Recommended): var iframehide="yes" var getFFVersion=navigator.userAgent.substring(navigator.userAgent.indexOf("Firefox")).split("/")[1] var FFextraHeight=parseFloat(getFFVersion)>=0.1? 16 : 0 //extra height in px to add to iframe in FireFox 1.0+ browsers function resizeCaller() { var dyniframe=new Array() for (i=0; i<iframeids.length; i++){ if (document.getElementById) resizeIframe(iframeids[i]) //reveal iframe for lower end browsers? (see var above): if ((document.all || document.getElementById) && iframehide=="no"){ var tempobj=document.all? document.all[iframeids[i]] : document.getElementById(iframeids[i]) tempobj.style.display="block" } } } function resizeIframe(frameid){ var currentfr=document.getElementById(frameid) if (currentfr && !window.opera){ currentfr.style.display="block" if (currentfr.contentDocument && currentfr.contentDocument.body.offsetHeight) //ns6 syntax currentfr.height = currentfr.contentDocument.body.offsetHeight+FFextraHeight; else if (currentfr.Document && currentfr.Document.body.scrollHeight) //ie5+ syntax currentfr.height = currentfr.Document.body.scrollHeight; if (currentfr.addEventListener) currentfr.addEventListener("load", readjustIframe, false) else if (currentfr.attachEvent){ currentfr.detachEvent("onload", readjustIframe) // Bug fix line currentfr.attachEvent("onload", readjustIframe) } } } function readjustIframe(loadevt) { var crossevt=(window.event)? event : loadevt var iframeroot=(crossevt.currentTarget)? crossevt.currentTarget : crossevt.srcElement if (iframeroot) resizeIframe(iframeroot.id); } function loadintoIframe(iframeid, url){ if (document.getElementById) document.getElementById(iframeid).src=url } if (window.addEventListener) window.addEventListener("load", resizeCaller, false) else if (window.attachEvent) window.attachEvent("onload", resizeCaller) else window.onload=resizeCaller </script> */ for($i=0; $i<5; $i++){ if($i != 0){ $start = $start + $max_items; $end = $end + $max_items; } echo "<td>"; for($x = $start; $x < $end; $x++){ $imageL= $path.$item[$x]; $img_path="http://ve-creative.com/test/8/$imageL"; // display the item echo '<center><p><img src= "'.$path.$item[$x] .'" height="100" width="100"></p></center>'; echo "<script type='text/Javascript'>loadintoIframe(iframeresize, demo2_edit.php?img=$img_path)'>[Edit / resize]</script>><br>"; /* NOT WITH A HREF, BUT WITH SCRIPT TYPE */ } echo "</td>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/146678-target-iframe/#findComment-770893 Share on other sites More sharing options...
anf.etienne Posted February 25, 2009 Author Share Posted February 25, 2009 thnaks i shall give this a try Quote Link to comment https://forums.phpfreaks.com/topic/146678-target-iframe/#findComment-770916 Share on other sites More sharing options...
DEVILofDARKNESS Posted February 25, 2009 Share Posted February 25, 2009 Also the link isn't close well; <script type='text/Javascript'>loadintoIframe(iframeresize, demo2_edit.php?img=$img_path)'>[Edit / resize]</script>><br> should be , I don't know how the loadintoframe works, because i'm not a javascript specialist, so if their still problems with the link, ask some on else for a better explanation <script type='text/Javascript'>loadintoIframe(iframeresize, demo2_edit.php?img=$img_path)[Edit / resize]</script> Quote Link to comment https://forums.phpfreaks.com/topic/146678-target-iframe/#findComment-770921 Share on other sites More sharing options...
anf.etienne Posted February 25, 2009 Author Share Posted February 25, 2009 lol thats fine....it isn't the javascript thats the problem i just don't know much about mixing php & javascript but im learning lol thanks again Quote Link to comment https://forums.phpfreaks.com/topic/146678-target-iframe/#findComment-770925 Share on other sites More sharing options...
anf.etienne Posted February 25, 2009 Author Share Posted February 25, 2009 hi, the code below that you told me to try does not generate the link that i need it to. echo "<script type='text/Javascript'>loadintoIframe(iframeresize, imgEdit.php?img=$img_path)[Edit / resize]</script><br>"; Quote Link to comment https://forums.phpfreaks.com/topic/146678-target-iframe/#findComment-770941 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.