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./";
-
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
5 Answers
Reset to default 3the 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.
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1742420278a4440544.html
评论列表(0条)