最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - document.locationparent.location - Can they be blocked? - Stack Overflow

programmeradmin1浏览0评论

I am using the above 2 mands on my website. It seems they work for 95% of people visiting the page it should trigger but for others it doesn't.

Does anyone know if these javascript mands can be blocked at all? I am having a real headache finding out why they don't work sometimes.

p.s I am not using these for spam or anything, just for processing payments.

Thanks.

EDIT: I have a tag replacement for JS being disabled. I am thinking more of a random blocking that a user isn't generally aware of. None of the people who have reported the issue would be likely to install a pop up blocker

I am using the above 2 mands on my website. It seems they work for 95% of people visiting the page it should trigger but for others it doesn't.

Does anyone know if these javascript mands can be blocked at all? I am having a real headache finding out why they don't work sometimes.

p.s I am not using these for spam or anything, just for processing payments.

Thanks.

EDIT: I have a tag replacement for JS being disabled. I am thinking more of a random blocking that a user isn't generally aware of. None of the people who have reported the issue would be likely to install a pop up blocker

Share Improve this question edited Jun 30, 2011 at 7:56 webnoob asked Jun 30, 2011 at 7:45 webnoobwebnoob 16k13 gold badges87 silver badges169 bronze badges 9
  • There is no location property of the HTMLDocument interface, perhaps you are confusing it with window.location. What "mands" are you using? What is it that "works for 95% of people"? – RobG Commented Jun 30, 2011 at 7:55
  • In terms of this not working, make sure the 5% aren't all using the same browser, if they are, you can link it to specific browser behaviour. – Abe Petrillo Commented Jun 30, 2011 at 7:56
  • The information I get back is VERY vague. Most of the people using the site are non technical and when you ask what browser, they say windows ... – webnoob Commented Jun 30, 2011 at 7:57
  • @RobG - Well it works normally ... Why would that happen? – webnoob Commented Jun 30, 2011 at 7:59
  • Yes some anti virus softwares might block JavaScript as "additonal security" so ask those clients what kind of Anti Virus they have installed or protection programs. – user447356 Commented Jun 30, 2011 at 8:05
 |  Show 4 more ments

3 Answers 3

Reset to default 4

Use window.location instead of document.location for full support across all browsers.

Are you using iframes? That's the only reason you should use window.parent or else window.parent just points to the current window.

If you're running this code inside of an iframe to change the parent windows locations (window.parent.location) - it will only work on the same domain. If the domains are different your code will fail.

There are work arounds to getting subdomain support working using document.domain but I'm already making too many assumptions in what your issue is.

Anything on the client side can be blocked. Two examples:

  1. Simply disable javascript in your browser
  2. Use a plugin which disables certain Javascript actions (something like TamperData for Firefox)

As RobG said in a ment, document.location is not part of a standard, though implemented in some browsers. I think you should be using window.location. See the notes in this mozilla reference on document.location that say document.location used to be a read-only property and is non-standard and window.location is remended instead.

parent.location can be blocked by same-origin security settings if you're framed and the parent frame is not the same origin as your frame.

发布评论

评论列表(0)

  1. 暂无评论