/    Sign up×
Community /Pin to ProfileBookmark

Different OS different Content in Iframe

First, I am a little confused about this and whether this is an appropriate approach. I have put this together so far. What it does is display a different html page into the IFrame based upon if the person clicks the link. However, this is not what I want to do. What I want to do, is if Windows XP is detected to display load1.html into the Iframe and if Windows Vista is detected to display load2.html into the iframe. Any help would be greatly appreciated. Thank you!

[CODE]<script type=”text/javascript”>

document.write(“<p>Browser’s user agent header: “);
document.write(navigator.userAgent + “</p>”);
if (navigator.userAgent.indexOf(“Windows NT 5.1”) > -1)
document.write(‘WINDOWS XP DECTECTED’)
else if (navigator.userAgent.indexOf(“Windows NT 6.0”) > -1)
document.write(‘WINDOWS Vista DECTECTED’)
else
document.write(‘No Os Detected’);

function loadIframe(iframeName, url) {
if ( window.frames[iframeName] ) {
window.frames[iframeName].location = url;
return false;
}
return true;
}
</script>

<a href=”load1.html” onclick=”return loadIframe(‘ifrm’, this,href)”>Page 1</a>
<a href=”load2.html” onclick=”return loadIframe(‘ifrm’, this.href)”>Page 2</a>

<div class=”iframe”>
<iframe name=”ifrm” id=”ifrm” src=”load1.html” frameborder=”0″>Your browser doesn’t support iframes.</iframe>
</div>[/CODE]

to post a comment
JavaScript

2 Comments(s)

Copy linkTweet thisAlerts:
@MrNobodyFeb 12.2009 — Keep these in this order:
[code=html]<iframe name="ifrm" src="" frameborder="0">Your browser doesn't support iframes.</iframe>
<script type="text/javascript">
var obj = self.frames['ifrm'];
if (navigator.userAgent.indexOf("Windows NT 5.1") > -1)
obj.location.href = "load1.html";
else if (navigator.userAgent.indexOf("Windows NT 6.0") > -1)
obj.location.href = "load2.html";
else obj.location.href = "loaderr.html";
</script>[/code]
Copy linkTweet thisAlerts:
@strfleauthorFeb 12.2009 — Thanks a ton for your help! You saved me countless hours of online tutorials.

Dave
×

Success!

Help @strfle 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.18,
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,
)...