3 posts by 2 authors in: Forums > Off Topic / Other
Last Post: October 3, 2011   (RSS)

By MickC - October 2, 2011

Hi,
This is probably more of a HTML/Javascript question, but you guys all seem pretty switched on with all this, so here goes!

I have an iframe on our homepage, the source of which is a scrolling list of machinery, out of the CMSB
When a unit is clicked on, I want the details page to open in an Iframe on another page of our website.

I have read http://www.interactivetools.com/iforum/P59754#59754
the only issue is that our homepage and the other page containing the iframe are html, not php

Re: [tom] Iframe targeting

By MickC - October 3, 2011

You are a godsend Tom!

everywhere else i looked, the mention of <iframes> sent people running.[:/]

Unfortunately, our existing site uses them, so i have to integrate with it.

I ended up getting it to work with a few mods,

with the link, i had to do a bit of directory navigating to get the results right, then add the listing link to it:

<a href="../draft/usedeq.htm?pageLink=<?php echo $record['_link'] ?>" target="_parent"><img src="<?php echo $upload['thumbUrlPath'] ?></a>

Then I had to change a little bit of the body code on the receiving page to make the iframe the right size and blend in like the old one did:

<script type="text/javascript">
var pageLink = gup("pageLink");
document.write( "<iframe src='"+pageLink+"'"+" width='100%' height='100%' scrolling='0' frameborder='0' allowtransparency='true'>");
</script>


The only other thing I had to do was modify the header script of the receiving page to display the original content if no link is specified, (by adding to the " if( results == null ) " line, otherwise opening that page directly from the existing menu gave a blank iframe.

<script type="text/javascript" >
function gup( name )
{
name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
var regexS = "[\\?&]"+name+"=([^&#]*)";
var regex = new RegExp( regexS );
var results = regex.exec( window.location.href );
if( results == null )
return "our_default_UsedMachinerypage.php";
else
return results[1];
}
</script>


Works like a charm now!

Thanks again mate :)