[英]Domain redirect problem with JQuery/JavaScript
我有一個奇怪的問題。 我有一個全屏圖像縮放器javascript(作為GOTOCHINA網站),在我的網站上效果很好。
然后,我購買了指向我網站上的域重定向,當突然重定向時,Internet Explorer 7和Internet Explorer 8給我這個錯誤
Messagge:不是有效的參數。
行:34
字符:17
URI:http://***********/scaler.js
該腳本是
var db=document.body;
var imag=document.getElementById('wallpaper');
var dbsize={};
var imgsrc=imag.src;
var keyStop=function(e){
var e=window.event||e||{};
var tag=e.target.tagName.toLowerCase();
if(tag!='textarea'&&!(tag=='input'&&(e.target.type=='text'||e.target.type=='password'))){
if(e.keyCode==32||e.keyCode==39||e.keyCode==40){
if(e.preventDefault)e.preventDefault();
else e.returnValue=false;
}
}
}
if(this.addEventListener)window.addEventListener('keydown',keyStop,false);
else window.attachEvent('onkeydown',keyStop);
setInterval(function(){
window.scrollTo(0,0);
if(imag.complete){
if(db.clientWidth!=dbsize.w||db.clientHeight!=dbsize.h||imag.src!=imgsrc){
imgsrc=imag.src;
var dbsizew=db.clientWidth;
var dbsizeh=db.clientHeight;
var newwidth=Math.round(dbsizeh*(imag.offsetWidth/imag.offsetHeight));
var nextvar=dbsizew>newwidth?dbsizew:newwidth;
imag.style.width=nextvar+'px';
}
}
},300);
換句話說,當我打開官方網站時,一切工作正常。 當我打開指向官方網站上的重定向域時...出現先前的錯誤。 該行就是這樣-> imag.style.width=nextvar+'px'
;
網站網址-> domain1(官方)-> www [d0t] stasi * group [d0t] it //不帶*,-> domain2(重定向域)-> www [d0t] villa * vittoria [d0t] it //不帶*
當前網站正在進步中
->
您正在使用任何AJAX嗎? 我猜想您正在經歷“單一來源策略”,該策略將您限制在同一域上的AJAX請求-因此,如果您具有domain1.com和domain2.com,並且都從domain1.com上提取AJAX,則它將將在domain2.com上失敗。
不建議在多個域上訪問同一站點,因為這對SEO不利(盡管可以通過多種方法來解決,例如規范的元標記)。 而是,將domain2.com重定向到domain1.com
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.