Wrox Programmer Forums
|
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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 22nd, 2004, 11:29 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 344
Thanks: 0
Thanked 1 Time in 1 Post
Default

I've just tried running it without a webserver and I get the titles up correclty from the alerts, but I then get the following error message :

objs[0] has no properties - headline.js line 176

If I rerun the page under a webserver locally I get the same error message but no alerts.

Having rechecked the base article I used as reference - http://img.com.com/i/tr/bldr/Ticker/exampleD.html - which still works in my NN, I'm really stuck on this one.

My About Netscape gives the following : Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0

Thanks for the help.
 
Old May 21st, 2004, 08:42 AM
cjj cjj is offline
Registered User
 
Join Date: May 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I have the same question. :(

My English is poor.
 
Old June 17th, 2004, 09:31 PM
Registered User
 
Join Date: Jun 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
i have been working on this RSS for weeks and now i m having the same question. really need your help!!!:(

can anybody answer that if it's solved? ;) i'll really appreciate it.
 
Old September 30th, 2004, 10:20 AM
Registered User
 
Join Date: Sep 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Althought I dont have exactly the same need as you, this works for me both in IE 6.0.28 and NS 7.1

html files and JS function

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
  <meta http-equiv="content-type" content="text/html; charset=windows-1250">
  <meta name="generator" content="PSPad editor, www.pspad.com">
  <title></title>

  <script>
  <!--



    function importXml(strFileName)
    {
      //pour Netscape Mozilla et similaire
        if (document.implementation && document.implementation.createDocument)
        {
            xmlDoc = document.implementation.createDocument("", "", null);
        xmlDoc.onload=function(){getTextFromXml();}
        }
        //pour IE
        else if (window.ActiveXObject)
        {
            xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
            xmlDoc.async = "false";
            xmlDoc.onreadystatechange=function(){if(xmlDoc.rea dyState == 4){getTextFromXml();}}
         }
         //ceux qui ne supportent pas
        else
        {
            alert('Your browser can\'t handle this script');
            return;
        }
        xmlDoc.load(strFileName);
    }

    function getNodeValue(strNodeName)
    {
        var xNode = xmlDoc.getElementsByTagName(strNodeName);

        if(xNode.length > 1)
        {
         alert('There is more than one node !');
       return false;
      }
      else if (xNode.length == 0)
      {
        return false;
      }
      else
      {
        if(xNode[0].text)
          return xNode[0].text;
        else if(xNode[0].firstChild)
          return xNode[0].firstChild.data
        else
          return false;
      }
    }

    function getTextFromXml()
    {
      var strTexte, elements, i;

      //construction d'un tableau d'élément en fonction des capacités des différents browsers
      elements = typeof document.all!='undefined' ? document.all : document.getElementsByTagName('*');
      for(i=0; i < elements.length; i++)
      {
        //alert(elements[i].tagName.toLowerCase());

        switch(elements[i].tagName.toLowerCase())
        {
          case "p" :
            strTexte = getNodeValue(elements[i].id);
            if(strTexte != false)
            {
              elements[i].innerHTML = strTexte;
            }
          break;

          case "input" :
            strTexte = getNodeValue(elements[i].id);
            if(strTexte != false)
            {
              elements[i].value = strTexte;
            }
          break;

          case "img" :
            strTexte = getNodeValue(elements[i].id);
            if(strTexte != false)
            {
              elements[i].alt = strTexte;
              elements[i].title = strTexte;
            }
          break;
        }
      }
    }

  //-->
  </script>


  </head>
  <body onload="javascript:importXml('test.xml');">

    <input type="button" value="" name="input_clic" id="input_clic" />
    <img id="img_test" name="img_test" src="apache_pb.gif" alt="" title="" />
    <p id="txt_accueil" name="txt_accueil"></p>

  </body>
</html>

The content of test.xml

<?xml version="1.0" encoding="windows-1250"?>
<root>
  <input_clic>cliquez ici</input_clic>
  <txt_accueil>Le contenu du paragraphe.</txt_accueil>
  <img_test>texte de l'image</img_test>
</root>

Hope this help.

---------
Goulh





Similar Threads
Thread Thread Starter Forum Replies Last Post
XML Javascript + Netscape equivalent sasidhar79 XML 0 October 19th, 2004 02:49 AM
XML from a DB recordset (removal of &lt;&gt;) Thodoris XML 3 July 13th, 2004 12:28 AM
Disabling copy/paste in both IE & Netscape Mekala HTML Code Clinic 0 July 2nd, 2004 04:24 AM
XML and netscape / mozilla madhukp XML 1 May 21st, 2004 04:01 PM
XML and netscape / Mozilla madhukp Classic ASP XML 0 May 3rd, 2004 04:24 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.