SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Member Baines's Avatar
    Join Date
    Apr 2003
    Location
    UK
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Function not defined! But why?

    Firstly, let me apologise. Javascript is not my thing but I’m just beginning to realise how powerful it can be.

    This is my first real outing, apart from simple modifications of downloaded scripts, so please be gentle with me.

    All I’m trying to do it change the content of a table cell with an onmouseover……..
    Code:
    <html>
    <head>
    <SCRIPT LANGUAGE="JSCRIPT">
    
    	
    	function changeText()
    	{
    		document.getElementById('description').innerHTML='You have now.....';
    	}
    
    </SCRIPT>
    
    </head>
    <body>
    
    
    
    <table width="500" border="1">
    	<tr>
    	<td width="200"><a href="http://www.some_url.com" target ="new" onmouseover='changeText();'>Some Url</a></td>
    
    	<td width="300"><div id="description">You have not yet pointed at the URL</div></td>
    
    	</tr>
    </table>
    </body>
    </html>
    This works a treat in IE6 but I’m buggered if I can get it to work in Mozilla (1.3 or 1.4)

    From what I’ve read, the document.getElementById should be fine in both and the innerHTML likewise……..

    Mozillas JS console reports "Error: changeText is not defined"

    Any comments gratefully received.

    Cheers

    Baines

  2. #2
    SitePoint Wizard davidjmedlock's Avatar
    Join Date
    Dec 2002
    Location
    Nashville, TN USA
    Posts
    1,688
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mozilla will not support 'language="jscript"'. Try changing to 'language="javascript"'.

    Actually, to be standards compliant, I believe you can leave out the language attribute completely and use 'type="text/javascript"'.

  3. #3
    SitePoint Wizard Bill Posters's Avatar
    Join Date
    Dec 2001
    Location
    UK
    Posts
    1,523
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    "jscript" is MSIE's own brand of javascript- and anything browser-specific is bad, mmm'kay?

    Even though the function itself is fine, the <script> tag contains language='jscript' which tells the browser that 'this bit is MSIE-specific', so even though the function inside the tags is healthy, it is still being ignored by non-IE browsers.

    Code:
    <script type="text/javascript">
    
    ...
    
    </script>
    ...and don't let me see you doing it again, y'hear me!?


    New Plastic Arts: Visual Communication | DesignateOnline

    Mate went to NY and all he got me was this lousy signature

  4. #4
    SitePoint Member Baines's Avatar
    Join Date
    Apr 2003
    Location
    UK
    Posts
    19
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Smile Deep Joy!

    You guys are unbelievable…….

    I’ve spent the last 4 hours looking at this, all the time wondering why the function wasn’t defined.
    This will teach me to start at the beginning and learn to walk before I can run……

    And a world record response time, can’t have been more than 10 minutes.

    Hero worship all round.

    The beer is on me next time you are in Stoke-on-Trent.

    Thanks

    Baines

  5. #5
    SitePoint Wizard davidjmedlock's Avatar
    Join Date
    Dec 2002
    Location
    Nashville, TN USA
    Posts
    1,688
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    11 minutes, actually. SPF is great about that, though. There's always someone who is ready and willing to help. I'm glad it worked for ya.

  6. #6
    SitePoint Member
    Join Date
    Feb 2005
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Exclamation External Function not defined! But why?

    Hi, i have my function not defined in external javascript but inside the .html the function work great !!.

    Code:
    <html>
    <head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link href="styles.css" rel="stylesheet" type="text/css">
    <script language="javascript" type="text/javascript" src="scripts2.js"></script>
    </head>
    Code:
    var TextBoxAry=new Array("");
    //var TextBoxCnt = 1;
    var notesAry=new Array("");
    var notesCnt = 0;
    var clundi = 0;
    var cmardi = 0;
    var cmercredi = 0;
    var cjeudi = 0;
    var cvendredi = 0;
    var cnotes = 0;
    
    function add(c,a1,jour){
    	switch (jour){
    	case 'lundi':
    		clundi++;
    		TextBoxCnt = clundi;
    		break;
    	case 'mardi':
    		cmardi++;
    		TextBoxCnt = cmardi;
    		break;
    	case 'mercredi':
    		cmercredi++;
    		TextBoxCnt = cmercredi;
    		break;
    	case 'jeudi':
    		cjeudi++;
    		TextBoxCnt = cjeudi;
    		break;
    	case 'vendredi':
    		cvendredi++;
    		TextBoxCnt = cvendredi;
    		break;
    	default : alert("Ajouter: Cette erreur ne devrait pas être à votre écran.");
    	}
    	if (c=='TEXTBOX'){
    	  TextBoxAry[TextBoxCnt] = document.createElement('INPUT');
    	  TextBoxAry[TextBoxCnt].type = 'TEXT';
    	  TextBoxAry[TextBoxCnt].size = a1;
    	  TextBoxAry[TextBoxCnt].name = jour+'Vol'+TextBoxCnt;
    	  TextBoxAry[TextBoxCnt].id = jour+'Vol'+TextBoxCnt;
    	  document.getElementById(jour+'Vol').appendChild(TextBoxAry[TextBoxCnt]);
    	  TextBoxAry[TextBoxCnt] = document.createElement('INPUT');  
    	  TextBoxAry[TextBoxCnt].type = 'TEXT';
    	  TextBoxAry[TextBoxCnt].size = a1;
    	  TextBoxAry[TextBoxCnt].name = jour+'Dep'+TextBoxCnt;
    	  TextBoxAry[TextBoxCnt].id = jour+'Dep'+TextBoxCnt;
    	  document.getElementById(jour+'Dep').appendChild(TextBoxAry[TextBoxCnt]);
    	  TextBoxAry[TextBoxCnt] = document.createElement('INPUT');
    	  TextBoxAry[TextBoxCnt].type = 'TEXT';
    	  TextBoxAry[TextBoxCnt].size = a1;
    	  TextBoxAry[TextBoxCnt].name = jour+'Arr'+TextBoxCnt;
    	  TextBoxAry[TextBoxCnt].id = jour+'Arr'+TextBoxCnt;
    	  document.getElementById(jour+'Arr').appendChild(TextBoxAry[TextBoxCnt]);
    	  TextBoxCnt++;
    	}
    }
    Anyone understand what happen!
    Thanx


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
  •