/    Sign up×
Community /Pin to ProfileBookmark

Almost completed Layer Swap.

I patched together code to grab a file from a url (stripped html) and
inject it into an IFrame for swappable layering. I still need it to pull
an onload default page though, but it has me scratching my head.

I tried <body onload=”loadOuter(‘main.html’)> but it morphed my layout
and just plain didn’t work in general. Any suggestions appreciated!

swaplayer.js

[code]

var srcFrame;

//External content into a layer
function loadOuter(doc) {
srcFrame = document.getElementById(“hiddenContent”);
srcFrame.src = doc;

// workaround for missing onLoad event in IFRAME for NN6
if (!srcFrame.onload) {
setTimeout(“transferHTML()”, 500)
}
}

function transferHTML(){
srcContent=”;
if (srcFrame.contentDocument){
srcContent=srcFrame.contentDocument.getElementsByTagName(“BODY”)[0].innerHTML;
}
else if (srcFrame.contentWindow){
srcContent=srcFrame.contentWindow.document.body.innerHTML;
}
document.getElementById(“outerDisplay”).innerHTML = srcContent
}

var DocAry=new Array(”);

function SelectList(v){
if (v>0){
loadOuter(DocAry[v-1]);
}
}
[/code]

And HTML mechanism and injection site

[code]
<a href=”#” onClick=”loadOuter(‘main.html’)”>home.</a>
…..
<iframe id=”hiddenContent” width=”200″ height=”200″ style=”position:absolute;visibility:hidden;width:auto;height:auto;” ></iframe>
[/code]

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@ehimeauthorOct 02.2008 — up, come on guys I really could use a hand here.
×

Success!

Help @ehime spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...