开发者

Domain redirect problem with JQuery/JavaScript

开发者 https://www.devze.com 2023-01-04 00:39 出处:网络
I got a strange problem. I have a fullscreen image scaler javascript (as GOTOCHINA website) that works very well on my website.

I got a strange problem. I have a fullscreen image scaler javascript (as GOTOCHINA website) that works very well on my website.

Then, I purchased a domain redirect pointing on my website and when redirecting suddenly internet explorer 7 and internet explorer 8 give me this error

Messagge: is not a valid argument.

Line: 34

Char: 17

URI: http://***********/scaler.js

The script is

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);

In other words when i open the official website everything's working correctly. When i open redirect domain pointing on official website... the previous error appears. The line is exactly this -> imag.style.width=nextvar+'px';

Websites url -> domain1 (official) -> www[d0t]stasi*group[d0t]it // without * and -> domain2 (redirectdomain) -> www[d0t]villa*vittoria[d0t]it // without *

currently websites are work in progres

         ->


Are you using any AJAX? I'd guess that you're experiencing the Single Origin Policy, which limits you to AJAX requests on the same domain - so if you have domain1.com and domain2.com, and are pulling in AJAX from domain1.com on both then it will fail on domain2.com.

Having the same site accessible on multiple domains is discouraged, as it's bad for SEO (although there are ways around this, such as canonical meta tags). Instead, redirect domain2.com to domain1.com

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号