The issue of links that open into a “New Window” have bothered many people for some time. At long last I am joining them. Included in this post are some sample SQL statements to help get rid of them.
It might be useful to put this tag,
"target="_blank" , into a historical context.
Back when I first started coding pages for this site in 1995, the world wide web was much closer to its origins (1980-1991) than we are to 1995 today. Most of us were trying to learn the standards of hand-coding HTML and whatever conventions were recognized “good etiquette” at the time.
The remarkable ability to create activated page elements called “links” distinguished hypertext markup from practically any other text display in the world. You click a link, you go to the referenced part of the page, or perhaps to a different page, or even a different website!
The ability to go offsite to another website created a problem and much confusion for early coders and users. Once you get to a new page, there is no visual way of determining how you got there. (There was a BACK button then as now). I was reading this page and I clicked this link; where in thunder did my page go, and how do I get back to it?”
"target="_blank" solved this easily: you click a link with this tag, and you get a new window for the new content – but your old window is still there, underneath.
This is 2009. Today, most or all browsers allow you the choice of opening a link in a new window, a new tab, or just replacing the old window (right-click the link to see available options).
Many users today consider “new windows” a contemptible form of hijacking. At first, I was honestly baffled by the occasional abusive letter about my own use of the tag. Didn’t the writer know how to close a window, or click a BACK button?
There are no BACK buttons on new windows. Increasingly, I felt frustrated in my own browsing to discover I had a fleet of browser windows to shut down before concluding a surfing session. Finally, I saw the light.
In other words, as one commentator, Johan Petersson, put it in his article regarding the
"target="_blank"tag, “Some web designers think their sites are so important that any external link must be opened in a new browser window”.
“However, no amount of clever (or stupid) tricks will change the fact that forcing new windows to open is disrespectful and hostile to web site visitors. A number of usability studies have shown that experienced web users will find this behaviour annoying and that beginners will get confused by it.”
We’ve come to agree with this. At this writing, we’ve tackled all the remaining legacy HTML pages as well. There should be no “new window” links left on this site.
Using a text editor to get rid of these pages in HTML is easy with the “find and replace” feature.
Here are some simple SQL statements that may be useful to anyone faced with the task of deleting scores or hundreds of references to
"target="_blank" from a MySQL database. These are set up for WordPress. Use the SELECT statements first to make sure you are targeting the right code population. Always export a MySQL backup before proceding. Then run your update tags.
If your text editor replaces vertical tick marks ['] with slanted ticks [‘], fix them before running the SQL. Slanted ticks will cause the statement to fail.
- SELECT * FROM wp_posts WHERE post_content LIKE '%_blank%
- update wp_posts set post_content = replace(post_content, 'target=\"_blank\"', '')
- SELECT * FROM wp_links WHERE link_name LIKE '%_blank%'
- update wp_links set link_target = replace(link_target, '_blank', '')
46 total views, 3 views today