SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member
    Join Date
    Apr 2009
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Problem With All browser except IE

    I use the following Jscript code and it works fine with IE but with all browsers like opera - Mozilla - Chrome - safari it doesn't work and don't know why ..
    please i need some help ..

    Code JavaScript:
    function showobject(o)
        {
            var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
            function loadXML(xmlFile) {
                xmlDoc.async = "false";
                xmlDoc.onreadystatechange = verify;
                xmlDoc.load(xmlFile);
                xmlObj = xmlDoc.documentElement;
            }
     
            function verify() {
                if (xmlDoc.readyState != 4) {
                    return false;
                }
            }
            loadXML("XMLObjects.xml");
     
     
     
            var id = o.id;
            var a = new Array();
            a = id.split("-");
     
            for(var i=1;i<5;i++)
            {
                var hidden = document.getElementById('selected');
                if(a[1] == i)
                {
                    var mybg = document.getElementById('video-' + i);
                    mybg.className = "divhover";
                    hidden.value = i;
                }   
                else
                {
     
                    var mybg = document.getElementById('video-' + i);
                    mybg.className = "div1";
     
                }
            }
     
     
     
            var curtitle = document.getElementById('currentTitle');
            curtitle.innerHTML = xmlObj.childNodes(a[1]-1).getAttribute('title')
            var curDesc = document.getElementById('currentDesc');
            curDesc.innerHTML = xmlObj.childNodes(a[1]-1).getAttribute('des')
     
     
     
            var paramValue;
            var embedSrc;
            embedSrc = xmlObj.childNodes(a[1]-1).getAttribute('url') + "&hl=" + xmlObj.childNodes(a[1]-1).getAttribute('hl') + "&fs=" + xmlObj.childNodes(a[1]-1).getAttribute('fs') + "&autoplay=" + xmlObj.childNodes(a[1]-1).getAttribute('autoplay');
            var myAnch = document.getElementById(id);
     
            var myDiv = document.getElementById('objectDiv');
            var objectembed = document.createElement('embed');
            myDiv.innerHTML = "";
            objectembed.setAttribute('src',embedSrc);
            objectembed.setAttribute('type',"application/x-shockwave-flash"); 
            objectembed.setAttribute('allowscriptaccess',"always");
            objectembed.setAttribute('allowfullscreen',"true");
            objectembed.setAttribute('width',"400");
            objectembed.setAttribute('height',"280");
            myDiv.appendChild(objectembed);
     
            xmlDoc = null;
            xmlObj = null;
            myAnch = null;
            mybg = null;
            myDiv = null;
            name = null;
            objectembed = null;
            curtitle = null;
            curDesc = null;
        }
    Code JavaScript:
    var xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
            function loadXML(xmlFile) {
                xmlDoc.async = "false";
                xmlDoc.onreadystatechange = verify;
                xmlDoc.load(xmlFile);
                xmlObj = xmlDoc.documentElement;
            }
     
            function verify() {
                if (xmlDoc.readyState != 4) {
                    return false;
                }
            }
            loadXML("XMLObjects.xml");
     
     
            drawdiv();
     
            function drawdiv() {
     
     
                var title;
                var imageurl;
                var desc;
     
     
                var str = "";
                for (var i = 1; i < xmlObj.childNodes.length + 1; i++) {
     
                    title = xmlObj.childNodes(i - 1).getAttribute('title');
                    imageurl = xmlObj.childNodes(i - 1).getAttribute('image');
                    desc = xmlObj.childNodes(i - 1).getAttribute('des');
     
                    if (i == 1) {
                        str += "<div class=\"divhover\" id=\"video-" + i + "\" onmouseover=\"changeBgOver(this);\" onmouseout=\"changeBgOut(this)\">";
                    }
                    else {
                        str += "<div class=\"div1\" id=\"video-" + i + "\" onmouseover=\"changeBgOver(this);\" onmouseout=\"changeBgOut(this)\">";
                    }
                    str += "<div class=\"imageContainer\">";
                    str += "<a id=\"image-" + i + "\" class=\"titleanch\" onclick=\"showobject(this);\">";
                    str += "<img id=\"img-" + i + "\" src=\"" + imageurl + "\" class=\"smallImage\" alt=\"\" />";
                    str += "</a>";
                    str += "</div>";
                    str += "<div class=\"videoListContent\">";
                    str += "<a id=\"title-" + i + "\" onclick=\"showobject(this);\" onmouseover=\"hover(this);\" onmouseout=\"out(this);\"><font color=\"#336799\" size=\"2pt\"><b>" + title + "</b></font></a>";
                    str += "<br />";
                    str += "<div id=\"videoDesc-" + i + "\" class=\"videoListDesc\">" + desc;
                    str += "</div>";
                    str += "<a id=\"play-" + i + "\" onclick=\"showobject(this);\" onmouseover=\"hover(this);\" onmouseout=\"out(this);\">";
                    str += "<img alt=\"\" src=\"play.png\" /></a></div></div>";
                    var maindiv = document.getElementById('currentVideosSection');
                    maindiv.innerHTML = str;
                }
            }


    I hope if someone help me ..

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,580
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    The "Microsoft.XMLDOM" and use of ActiveX should be a hint that this is a Microsoft-only technology. It won't work in any other browser.

  3. #3
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,048
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)
    Hi AmRoSH, welcome to the forums.

    ActiveX controls are a Windows/IE only thing (same is true for the jscript flavor of javascript and vbscript).

    But I think you may be able to get the XML file by using XMLHttpRequest (AJAX), and then do the DOM manipulations.

  4. #4
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,684
    Mentioned
    100 Post(s)
    Tagged
    4 Thread(s)
    Here's some cross-browser code for the working with the xml dom
    http://www.w3schools.com/Dom/dom_parser.asp
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  5. #5
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    17,048
    Mentioned
    187 Post(s)
    Tagged
    2 Thread(s)
    Excellent link. I've never used it so I forgot all about "implementation". Much better than using AJAX to do it after the page loads.

  6. #6
    SitePoint Member
    Join Date
    Apr 2009
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Red face

    Thanks all for ur replies and i will try your ideas and i will back to tell you the result .
    i'm really appreciate that.


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
  •