Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Web Programming > JavaScript > Javascript How-To
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old August 18th, 2005, 04:16 PM
Registered User
 
Join Date: Aug 2005
Location: , , .
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default JavaScript & XML & NN

I am trying to develop an App that will rotate Flash Movies without a postback. The Flash parameters are stored in a XML file and after loading the XML file I go through the nodes and build the string. I did not include the tags in the XML file (i.e. "<", ">" etc) because I thought it would be easy to just include them when I build the string in js. I AM NOT GOOD WITH JavaScript! (it would be easier to do this in .Net but I need the rotation to occur without postback) However after this script is debugged and working in IE, NN, FF etc. This will become apart of a .Net code behind file for a user control. Loading the xmlDoc works on IE, NN, FF etc. The problem is the function where I build the string:

The Script:

function createflsMovie()
{
var x = xmlDoc.getElementsByTagName('Ad');
var flsStr = ' ';
flsStr += '<' + x[0].childNodes[0].firstChild.nodeValue + x[0].childNodes[1].firstChild.nodeValue + ' ';
    flsStr += x[0].childNodes[2].firstChild.nodeValue + x[0].childNodes[3].firstChild.nodeValue + ' ';
    flsStr += x[0].childNodes[4].firstChild.nodeValue + x[0].childNodes[5].firstChild.nodeValue + ' ';
    flsStr += x[0].childNodes[6].firstChild.nodeValue + x[0].childNodes[7].firstChild.nodeValue + ' ';
    flsStr += x[0].childNodes.firstChild.nodeValue + x[0].childNodes[9].firstChild.nodeValue + ' ';
    flsStr += x[0].childNodes[10].firstChild.nodeValue + x[0].childNodes[11].firstChild.nodeValue + ' ';
    flsStr += x[0].childNodes[12].firstChild.nodeValue + x[0].childNodes[13].firstChild.nodeValue + ' ';
    flsStr += '> \n';
    flsStr += '<' + x[0].childNodes[14].firstChild.nodeValue + x[0].childNodes[15].firstChild.nodeValue + ' ';
    flsStr += x[0].childNodes[16].firstChild.nodeValue + x[0].childNodes[17].firstChild.nodeValue + ' ';
    flsStr += '/' + '> \n';
    flsStr += '<' + x[0].childNodes[18].firstChild.nodeValue + x[0].childNodes[19].firstChild.nodeValue + ' ';
    flsStr += x[0].childNodes[20].firstChild.nodeValue + x[0].childNodes[21].firstChild.nodeValue + ' ';
    flsStr += '/' + '>';
    flsStr += '<' + x[0].childNodes[22].firstChild.nodeValue + x[0].childNodes[23].firstChild.nodeValue + ' ';
    flsStr += x[0].childNodes[24].firstChild.nodeValue + x[0].childNodes[25].firstChild.nodeValue + ' ';
    flsStr += '>';
    flsStr += '<' + x[0].childNodes[26].firstChild.nodeValue + x[0].childNodes[27].firstChild.nodeValue + ' ';
    flsStr += x[0].childNodes[28].firstChild.nodeValue + x[0].childNodes[29].firstChild.nodeValue + ' ';
    flsStr += '> \n';
    flsStr += '<' + x[0].childNodes[30].firstChild.nodeValue + x[0].childNodes[31].firstChild.nodeValue + ' ';
    flsStr += x[0].childNodes[32].firstChild.nodeValue + x[0].childNodes[33].firstChild.nodeValue + ' ';
    flsStr += x[0].childNodes[34].firstChild.nodeValue + x[0].childNodes[35].firstChild.nodeValue + ' ';
    flsStr += x[0].childNodes[36].firstChild.nodeValue + x[0].childNodes[37].firstChild.nodeValue + ' ';
    flsStr += x[0].childNodes[38].firstChild.nodeValue + x[0].childNodes[39].firstChild.nodeValue + ' ';
    flsStr += x[0].childNodes[40].firstChild.nodeValue + x[0].childNodes[41].firstChild.nodeValue + ' ';
    flsStr += x[0].childNodes[42].firstChild.nodeValue + x[0].childNodes[43].firstChild.nodeValue + ' ';
    flsStr += x[0].childNodes[44].firstChild.nodeValue + x[0].childNodes[45].firstChild.nodeValue + ' ';
    flsStr += x[0].childNodes[46].firstChild.nodeValue + x[0].childNodes[47].firstChild.nodeValue + ' ';
    flsStr += x[0].childNodes[48].firstChild.nodeValue + x[0].childNodes[49].firstChild.nodeValue + ' ';
    flsStr += x[0].childNodes[50].firstChild.nodeValue + x[0].childNodes[51].firstChild.nodeValue + ' ';
    flsStr += '>' + '<' + '/' + 'EMBED>' + '<' + '/' + 'Object>'

This works fine in IE (the movie plays in the browser) but I get nothing in NN, FF. (no exceptions or nothing)

So I started to break the script down and noticed some things that are different:
ex)
In IE the first available Node would be [0]
In NN it is [1].

So I tried this in the loadXML();

var c = 0
function importXML()
{
    if (document.implementation && document.implementation.createDocument)
    {
        xmlDoc = document.implementation.createDocument("", "", null);
        xmlDoc.onload = createTable;
                c++;
    }
    else if (window.ActiveXObject)
    {
        xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
        xmlDoc.onreadystatechange = function () {if (xmlDoc.readyState == 4) createTable()};
     }
    else
    {
        alert('Your browser can\'t handle this script');
        return;
    }
    xmlDoc.load("../ctrlTemp/xml/intAd/intFlsAdSysblk.xml");
}

Now the variable c would keep my node count and I figured that I would increase the value after each line.

ex)
flsStr += '<' + x[0].childNodes[c].firstChild.nodeValue;
c++;
flsStr += x[0].childNodes[c].firstChild.nodeValue + ' ';
c++;

etc.
This also worked for IE and it would work for NN if I had only one line but for some reason the concactenations are not liked well by NN, also when I use c++ more that once NN does not like it either. It also seems that NN does not like the '<' + ... either. Can some one please enlighten me as to how to get this script NN friendly?

Oh the output is like so:

document.getElementById('flsAd').innerHTML = (c);
}



</SCRIPT>
    </head>

    <body onLoad="importXML()">
        <form runat="server">

        <Div ID="flsAd"></Div>
        </form>
    </body>
</html>

Which also works!

Please Help!!



Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
JavaScript & XML lmod Javascript 1 August 24th, 2005 09:24 AM
Javascript && keeps turnig into &amp;&amp; ayrton Pro VB.NET 2002/2003 3 June 27th, 2005 04:34 PM
Linux & KDE & C++ & QT & MYSQL & Kdevelop Munnnki Linux 0 January 2nd, 2005 05:41 PM
xml & javascript shine XML 1 December 24th, 2003 12:45 PM
xml & javascript shine Javascript How-To 0 December 24th, 2003 07:25 AM



All times are GMT -4. The time now is 02:28 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.