/    Sign up×
Community /Pin to ProfileBookmark

Changing visibility of Iframe

Hey world! I’m REALLY new to javascript and i wanted to make a simple script that shows or hides an Iframe. Here’s an example of what i think would work but doesn’t:

[CODE]<a href=”javascript:showHide()”>Show or Hide Frame</a>
<iframe src=”http://www.google.com” name=”google” id=”google” style=”visibility:visible”></iframe>
<script type=”text/javascript”>
function showHide(){
if (document.getElementById(“google”).style.visibility == “visible”){
document.getElementById(“google”).style.visibility == “hidden”;
} else if (document.getElementById(“google”).style.visibility == “hidden”){
document.getElementById(“google”).style.visibility == “visible”;
}
}
</script>[/CODE]

Can someone please tell me what’s wrong???

to post a comment
JavaScript

4 Comments(s)

Copy linkTweet thisAlerts:
@MrNobodyJan 18.2009 — You have errors in your script (double equal signs for assignment operations), but the fact that the IFRAME source is an external domain may make it impossible for you to control the IFRAME via JavaScript.
Copy linkTweet thisAlerts:
@WutuauthorJan 18.2009 — How about if i put a div tag around the iframe and access the div thru javascript instead of the iframe?
Copy linkTweet thisAlerts:
@MrNobodyJan 18.2009 — Sounds good.
Copy linkTweet thisAlerts:
@WutuauthorJan 18.2009 — still doesnt work, can you fix errors in my script?



edited: nevermind...
×

Success!

Help @Wutu 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.1,
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,
)...