Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
a tricky javascript/iFrame issue
Hi,
So I’ve done a good bit of hunting around today to piece together a solution to my problem. And it works, just not completely and I’m such a javascript/DOM dolt that I can’t seem to figure it out.
The problem:
My client insisted on using an iFrame to present the pages of his band’s site. Anticipating that he’ll eventually pass out a url like http://www.hisband.com/tour – I’ve had to come up with a way to force the page (normally in an iFrame) to load it’s parent.
Most importantly, I want the iFrame to “repopulate” with the linked section – in this case /tour
With regular HTML, the below solution works, but with textpattern’s structure, it’s not working completely. The orphaned page essentially just reloads the index.php with the default (/home) section in the iFrame. I’ve poured over the script as much as I am able and cannot glean the problem…
The solution
First off – here’s the site. It’s in development, but you’re welcome to look: http://funkngroove.davebias.org
Here is the code in the “orphaned” page. This code is placed in the headers of all my section pages (i’ve removed the “script language javascript” stuff so the code will show here):
/* try { if (top self) {top.location.href='index.php'; } } catch(er) { } */
if (window top) {
var url=‘window.location.replace(“index.php?var1=‘window.location.href’”)’;
eval(url);
}
Here is the code in the index.php page:
var text = window.location.href;
function delineate(str) {
theleft = str.indexOf(“=”) + 1;
theright = str.indexOf(“&”);
return(str.substring(theleft, str.length));
}
url=delineate(text)
function refreshFrame() {
if(dastuff.location!=url&&url!=location.href)
dastuff.location.replace(url);
}
… and I added body onload=“refreshFrame();”
(dastuff is the name of the iFrame, by the way)
I’m sure that someone out there who is familiar with both Textpattern and javascript will immediately see the problem.
I’ve narrowed it down to the code in the index.php page, because when I remove it totally, the orphaned page still reloads the index.php page.
I’m almost certain that the problem is somehow related to the location.href statements either in the orphaned page code or the index page code since Textpattern deals with page links in its own way…
Any help on this matter will be GREATLY appreciated. Even if it’s just a link to a case where someone with this particular problem has come up with a solution.
thanks!!!
Dave Bias
Last edited by davebias (2006-04-24 21:18:48)
Offline
Pages: 1