/    Sign up×
Community /Pin to ProfileBookmark

Javascript and Iframe?

I’m working on a page where all content is opened within an iframe.

The navigation images swap on rollover. Is there any possible way to get the images to stay on the rollover state when the page is open in the iframe?

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@KorDec 08.2008 — By short :yes.

The exact way is up to the way you have named your pages. Or the HTML code of your menu. The solutions should be custom; but so far you have posted insufficient information.
Copy linkTweet thisAlerts:
@IHTPbeckettauthorDec 08.2008 — The HTML is simple. Just images and links.

[CODE]<div id="nav">
<a href="culture.html" target="iframe"><img src="images/nav1.jpg" oversrc="images/nav1_2.jpg" /></a><a href="main.html" target="iframe"><img src="images/nav2.jpg" oversrc="images/nav2_2.jpg" /></a><a href="contact.html" target="iframe"><img src="images/nav3.jpg" oversrc="images/nav3_2.jpg" /></a><a href="clientlogin.html" target="iframe"><img src="images/nav4.jpg" oversrc="images/nav4_2.jpg" /></a>
</div>[/CODE]


Then here is what I used for the rollover.

[CODE]function SimpleSwap(el,which){
el.src=el.getAttribute(which || "origsrc");
}

function SimpleSwapSetup(){
var x = document.getElementsByTagName("img");
for (var i=0;i<x.length;i++){
var oversrc = x[i].getAttribute("oversrc");
if (!oversrc) continue;


x[i].oversrc_img = new Image();
x[i].oversrc_img.src=oversrc;

x[i].onmouseover = new Function("SimpleSwap(this,'oversrc');");
x[i].onmouseout = new Function("SimpleSwap(this);");

x[i].setAttribute("origsrc",x[i].src);
}
}

var PreSimpleSwapOnload =(window.onload)? window.onload : function(){};
window.onload = function(){PreSimpleSwapOnload(); SimpleSwapSetup();}[/CODE]



What would I need to do to get the rollover images to stay on the rollover state while the page is open in the iframe?
Copy linkTweet thisAlerts:
@IHTPbeckettauthorDec 08.2008 — I desperately need a solution to this problem.

Anyone? Please?
×

Success!

Help @IHTPbeckett 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...