/    Sign up×
Community /Pin to ProfileBookmark

Changing style within iFrame w/ Javascript

I have a table displaying MySQL query results…many of them…in a standalone iFrame within a static page.

What I want to do is use Javascript to change the backgroundColor of the table row onmouseover. I have this:

[code]
<tr id=”myRow”><td>data</td><td>data</td></tr>
[/code]

What I’m trying to do is within each table data cell:

[code]
<td><a onMouseover = “document.frames[“myFrame”].getElementById(“myRow”).style.backgroundColor = ‘blue’;”>link</a>
[/code]

I can’t find a way to access the ID element within the same iFrame as the mouseover call. Any ideas?

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@toicontienDec 18.2007 — You're missing one piece in your code:
document.frames["myFrame"].[B]document[/B].getElementById("myRow").style.backgroundColor
Also note that if the domain name on which the JavaScript is hosted is not the same domain name of the HTML document loaded in the IFRAME, that JavaScript cannot access the window object of the IFRAME. Internet Explorer can, but shouldn't be allowed to. Web browsers block the ability to script across domains.
×

Success!

Help @musclehead 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.28,
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,
)...