Stop pop-ups with URL
I've been asked a question, and don't know if there is an answer.
"do you know if there is some code you can put into URLs to block pop-ups?"
This isn't using pop-up blocking software or toolbars etc, but a par开发者_如何学JAVAameter in the URL. Almost opposite to the target="_blank" for instance.
Assuming I'm reading your question right, it sounds like you want to block people from being able to open links in new windows/tabs within your site? There is nothing native in HTML you can do to block this. But you could use some javascript to do it:
<a href="#" onclick="window.location.href='http://www.google.com'; return false;">Link</a>
Now, mind you, this really breaks the way the anchor tag is supposed to work and presents a number of problems. If someone has javascript disabled, they can't use any of your links. I'd assume it'll also present problems for search-engine spiders as I doubt they follow javascript logic like that.
I'd personally avoid implementing something like this though and hate any site that went out of it's way to prevent me from opening a link in a new tab.
You can't do it for pages that aren't yours unless you're using a popup blocker.
If you're talking about making sure your own site doesn't open links in a new window you can do something like this within the <head> and </head> tags:
<base target="_self" />
However, I'm pretty sure this is the default anyway and will not keep a link that manually has it's target="_blank" from opening in a new window so I doubt it'll do you any good.
精彩评论