Jump to content

target iframe


anf.etienne

Recommended Posts

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>";
    }

    ?>

Link to comment
Share on other sites

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>";
    }
   
    ?>

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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>";
    }
   
    ?>

Link to comment
Share on other sites

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 :D

<script type='text/Javascript'>loadintoIframe(iframeresize, demo2_edit.php?img=$img_path)[Edit / resize]</script>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.