SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast [ DigitaL ]'s Avatar
    Join Date
    Oct 2005
    Location
    Here
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Javascript permission denied

    I am getting permission denied error using this code:

    I am trying to get marquee from other website. Please help me

    Code:
    <script>
    var currentState = 'started';
        function tickerPlay(dir){
            var tickerObj = document.getElementById('tickerObj');
            var pauseImage = document.getElementById('pauseImage');
            if (dir == 1) {
                tickerObj.direction = 'left'; 
                tickerObj.start(); 
                currentState = 'stopped';
                pauseImage.click();
            }else if(dir == -1) {
                tickerObj.direction = 'right'; 
                tickerObj.start(); 
                currentState = 'stopped';
                pauseImage.click();
            }else {
                // save last dir, restart
                if (currentState == 'started') { 
                    tickerObj.stop();
                    event.srcElement.src = event.srcElement.playImage;
                    currentState = 'stopped';
                }else {
                    event.srcElement.src = event.srcElement.stopImage;
                    tickerObj.start();
                    currentState = 'started';
                }
                
                
            }
        }
     var xmlHttp;
    var sURL = 'http://www2.dsm.com.qa/DSMTicker/ticker.htm';
    /////DSM 20 IDX /////
    function RequestTicker()
    { 
        var url= sURL + "";
        //var url= "ticker1.htm";
        xmlHttp=GetXmlHttpObjectTicker(onSuccessTicker) 
        xmlHttp.open("GET", url , true) 
        xmlHttp.send(null) 
    }
    
    function onSuccessTicker() 
    { 
        var resp = "";
        if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
        { 
            //alert(xmlHttp.responseText); 
            var marqObj = document.getElementById('tickerObj');
            resp = xmlHttp.responseText;
            var dt = resp.split(';');
            var ln = dt.length;
            var ch=0;
            if(marqObj.innerHTML == "")
                ch = 1; 
                var ticker = '';//'<MARQUEE class=ticker id=tickerObj dir=ltr onmouseover=this.scrollDelay=35; onmouseout=this.scrollDelay=20; trueSpeed scrollAmount=1 scrollDelay=20 width="99&#37;">'
            for(var i=0;i<ln-5;i=i+5)
            {
                var img = String(dt[i]);
                var ar  = dt[i+1];
                var eng = dt[i+2];
                var clr = String(dt[i+3]).substr(2);
                var url = dt[i+4];
                var id  = img.substr(img.indexOf('/images/')+8, 4);
                if(ch == 1){
                ticker =  ticker 
                    +  '<SPAN dir=ltr style="CURSOR: hand" onclick="window.location=\'/dsm/EN_' + String(id).toUpperCase() + '?id=' + String(id).toUpperCase() +'\'">'
                +  '<span dir=ltr><img src="' + img + '"></span>'
                +  '<SPAN dir=ltr id=' + id + ' style="font-size: 13px;font-weight: bold;color: #' + clr + '">' + eng + '</SPAN>'
                +  '</SPAN>'
                +'&nbsp;&nbsp;'
                }
                else
                    document.getElementById(id).innerHTML = eng;
            }
            if(ch == 1)
                marqObj.innerHTML = ticker;
        } 
    } 
    
    ///End 20 DSM IDX/////
    
    function GetXmlHttpObjectTicker(handler)
    { 
        var objXmlHttp=null
    
        if (navigator.userAgent.indexOf("Opera")>=0)
        {
            alert("This example doesn't work in Opera") 
            return 
        }
        if (navigator.userAgent.indexOf("MSIE")>=0)
        { 
            var strName="Msxml2.XMLHTTP"
            if (navigator.appVersion.indexOf("MSIE 5.5")>=0)
                {
                    strName="Microsoft.XMLHTTP"
                } 
            try
            { 
                objXmlHttp=new ActiveXObject(strName)
                objXmlHttp.onreadystatechange=handler 
                return objXmlHttp
            } 
            catch(e)
            { 
                alert("Error. Scripting for ActiveX might be disabled") 
                return 
            } 
        } 
        if (navigator.userAgent.indexOf("Mozilla")>=0)
        {
            objXmlHttp=new XMLHttpRequest()
            objXmlHttp.onload=handler
            objXmlHttp.onerror=handler 
            return objXmlHttp
        }
    }
    
    RequestTicker();
    setInterval(RequestTicker,5000);
    </script>

  2. #2
    SitePoint Zealot krt's Avatar
    Join Date
    Sep 2005
    Location
    Australia
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    For security reasons, there are restrictions when remote servers are involved.

    See: http://cristian.nexcess.net/ajax/fou...ping/ping.html

  3. #3
    SitePoint Enthusiast [ DigitaL ]'s Avatar
    Join Date
    Oct 2005
    Location
    Here
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    solution?

  4. #4
    SitePoint Zealot krt's Avatar
    Join Date
    Sep 2005
    Location
    Australia
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did you read what was in the article I linked to? Or more importantly, did you see the links for info on signing scripts for Mozilla browsers and more tutorials? Googling "ajax remote servers" will also help. Sorry I can't give an out-of-the-box solution but I'd rather not spend the time with the solution here and addressing key points.

  5. #5
    SitePoint Enthusiast [ DigitaL ]'s Avatar
    Join Date
    Oct 2005
    Location
    Here
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Aite. Thanks for your help.

    If someone else can help with more details. I will appreciate it.

  6. #6
    SitePoint Addict jtrelfa's Avatar
    Join Date
    Oct 2004
    Location
    Troy, Mi
    Posts
    231
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use a proxy file on your own domain. Then you can link to the other site on the server-side. You can't use client-side javascript to get data from another domain.

    There are a ton of sites out there dedicated to creating "mashups" of aggregated data from different sites into one. Poke around some of these sites and see how it's done.
    var me = null;


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •