开发者

document.location / parent.location - Can they be blocked?

开发者 https://www.devze.com 2023-03-16 04:30 出处:网络
I am using the above 2 commands on my website. It seems they work for 95% of people visiting the page it should trigger but for others it doesn\'t.

I am using the above 2 commands 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 commands 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.

T开发者_如何学Gohanks.

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


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 comment, 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 recommended 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

精彩评论

暂无评论...
验证码 换一张
取 消