我这样说了不起。 我正试图写一下长篇大论,其中:
- Detect www.website.com/anypage.html. If this website is detected, then do the following.
- Don t load the URL.
- Instead, write a blank document with a hyperlink to www.website.com/anypage.html?ie=UTF8
文字在文件一开始(在清单中)。
我的守则是:
侦查:
var regExp = /website.com/gi;
var match = 0;
testString = window.location.href.toString();
if(regExp.test(testString) {
match = 1;
与URL和UTF8编码标签链接的书写空白文件:
document.write("<a href=" + window.location.href + "?ie=UTF8>Title of Link</a>");
这只是一个空白页。 没有人有什么想法?
感谢!
EDIT:这里是一部完整的法典:
checklink(); // If there is a match, then checklink will return a 1. If it s already tagged, it will return a 5.
var matchLink = null;
if (checklink() === 1) {
matchLink = window.location.href.toString();
if (checklink() != 1) {
matchLink = null;
function checklink() { //checks to see if the current URL matches website.com
var regExp = /website.com/gi,
testString = window.location.href.toString(),
match = 0,
tagged = 0;
if (regExp.test(testString)) { //if there is a match, returns 1
match = 1;
var regExp2 = /UTF8/gi;
if (regExp2.test(testString)) { //if UTF8 is found, then it returns 5
tagged = 5;
return(match + tagged);
function tagUTF() {
if (matchLink) {
var newLink = matchLink + "?ie=UTF8";
document.write("<a href="" + newLink + "">Link</a>");
if (matchLink) {
tagUTF();
}