While copying files in Microsoft Windows you might be asked whether you want to replace an existing file or folder. You will be given four options “Yes”, “Yes to All”, “No” and “Cancel”. What about “No to All”? Performing a “No to All” function is extremely simple.
Tag Archives: computer
XHTML Strict & target=”_blank” (and _top)
I had made a post a few days ago regarding the problem with embedding flash (swf) into XHTML and still validating. That was an extremely simple fix, all you really had to do was remove code to get it to work (in other words, you optimized your code).
Getting XHTML to validate while using the target="_blank" value, on the other hand, takes a bit of code. Not that this is a problem, we’ve found the code you need!
First off, here’s the problem:
|
1 |
<a href="/test.html" target="_blank">testing</a> |
Here is what you’ll have after we fix the problem:
|
1 |
<a href="/test.html" rel="blank">testing</a> |
I’ll get straight to the point, if you want to dissect the code you can probably Google a line or two from it and get the page where I found the information.
This is what you put in your <head></head> tags:
|
1 |
<script type="text/javascript" src="/include/target.js"></script> |
This is what you put in the file located at /include/target.js:
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
function externalLinks() { if (!document.getElementsByTagName) return; var anchors = document.getElementsByTagName("a"); for (var i=0; i<anchors.length; i++) { var anchor = anchors[i]; if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "top") { anchor.target = "_top"; } else if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "blank") { anchor.target = "_blank"; } } } window.onload = externalLinks; |
That’s it! The original code I found was lacking, it only had the option to use an external window (_blank). My better code lets you also do a target="_top" command with the rel="top" method. So now you can use both rel="top" and rel="blank".
