/    Sign up×
Community /Pin to ProfileBookmark

If then else question

Hi there,

Can someone give me any idea why the following works in every other browser except IE?


—–

if (site == ‘http://www.thenoiseroom.com/index.html‘ || site == ‘http://www.thenoiseroom.com/‘ || site == ‘http://www.thenoiseroom.com/index.htm‘ || site == ‘http://www.thenoiseroom.com/leftmenuframe.html‘ || site == ‘http://www.thenoiseroom.com/frameset.html‘ || site == ‘http://www.thenoiseroom.com/topframe.html‘ || site == ‘http://www.thenoiseroom.com/toplineframe.html‘ || site == ‘http://www.thenoiseroom.com/topmenuframe.html‘ || site == ” || site == null) {
document.writeln (‘<frame src=”mainframe.php” name=”mainFrame” scrolling=”YES” noresize>’);
}


——

In IE it doesn’t recognise that the value site is [url]http://www.thenoiseroom.com/[/url]

Any help greatly appreciated!

Thanks
rob

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@KorFeb 11.2004 — what is that [b]site[/b] come from? What kinda variable is?
Copy linkTweet thisAlerts:
@speightrpauthorFeb 11.2004 — Hi there,

Thanks for your reply.

The variable site is

site = document.referrer

Look forward to any thoughts


Cheers

Rob
Copy linkTweet thisAlerts:
@TheBearMayFeb 11.2004 — That would be your problem...

document.referrer is generally null in IE
Copy linkTweet thisAlerts:
@speightrpauthorFeb 11.2004 — Hi there,

The thing is when I get the variable site displayed via an alert in IE it DOES show the correct URL however for some reason the if statement does not seem to be picking it up.

Also if it is NULL the if statement should be true but it doesn't do what is contained in it!

Any ideas?

Cheers

Rob
Copy linkTweet thisAlerts:
@TheBearMayFeb 11.2004 — Well if you're getting a value how about trying:

[code=php]
if (site.substring(0,27) == "http://www.thenoiseroom.com" || site == "" ||
site == null) {
...[/code]
Copy linkTweet thisAlerts:
@speightrpauthorFeb 11.2004 — Hey Chaps,

Thanks for the ideas but I have fixed it. It turns out that document.referrer in IE returns :

http://www.yoursite.com

whereas other browsers return

http://www.yoursite.com/

Simple but frustrating when you miss it!

Cheers

Rob
×

Success!

Help @speightrp 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.5,
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: @Yussuf4331,
tipped: article
amount: 1000 SATS,

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

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