admin管理员组

文章数量:1336659

I have a situation where a PC user's browser (I don't know which browser is it) doesn't have support for location.href, .asp.

JavaScript is on. Cause fancyBox shows up login popup, which result is - location.href change to ./admin.php?act=loggedok (as example)

Can anybody tell me how to detect this and how to process this issue?

Is this possible to lock out this JS code?

location.href = "/";

I have a situation where a PC user's browser (I don't know which browser is it) doesn't have support for location.href, http://www.w3schools./jsref/prop_loc_href.asp.

JavaScript is on. Cause fancyBox shows up login popup, which result is - location.href change to ./admin.php?act=loggedok (as example)

Can anybody tell me how to detect this and how to process this issue?

Is this possible to lock out this JS code?

location.href = "http://google./";

Share Improve this question edited Jul 1, 2011 at 13:17 publikz. asked Jun 29, 2011 at 21:34 publikz.publikz. 9611 gold badge12 silver badges22 bronze badges 3
  • 2 It doesn't sound like you know what the root cause is. I doubt it's location.href. – Stefan Kendall Commented Jul 1, 2011 at 13:24
  • Yes, corporative clients - are great :( No information, - just "not works" :( – publikz. Commented Jul 2, 2011 at 23:42
  • Dear Stefan. it sounds like i find an answer ... i was amazed, when understood this. Hmm, really sometimes it not work. In IE9 as ex. – publikz. Commented Feb 27, 2012 at 13:27
Add a ment  | 

5 Answers 5

Reset to default 3

the location object of the navigator is supported everywhere.. what you can do is to make a simple check if location is arround and then react to it as you need..

if ( window.location){ //or if (location in window) for modern browsers..
    window.location.href="www.google.";
}
else{
    alert("please enter www.google. into your address bar"); // :P
}

Btw; in a noscript tag, you cant do any javascript, so you cant "react to the user having javascript off". But you can display additional html in such a way, that shows the user he still lives in the 90's and should update his IE3 and enable javascript ;)

You need to be sure that Javascript support in user's browser is turned on. As you can see on w3schools web site it is supported by all main browsers.

This link can help: Mozilla: location

why don't you use

document.location.href = 'http://google./';

instead?

It works on all browsers unless they have javascript disabled

The problem is either that javascript is not supported, turned off, or the browser does not support the location object which is basically shorthand for window.location. thus use:

window.location.href="http://www.google.";

As Andron said all major browsers should support it unless they specifically have javascript disabled. You can tell the user about this using the <noscript> tag.

本文标签: javascriptWhich browsers don39t support locationhref and how to process thisStack Overflow