Computer problems,Computer help
*AX SOFT>>>Programming & Design

Why is this javascript not working in FireFox? Nothing shows.?


Using FireFox, can you see a wisdom phrase below the title at my blog: http://back2nature.blogspot.com.

Is it that I must place the function in the head section?

------

<script language="JavaScript">

// ***** Modify the messages here ***** //
// ***** As many messages as you can provide. ***** //
// ***** May include individually designed formatting, or url link.
***** //
var Message = new Array(
"Message 1",
"Message 2",
"Message 3"
);
function randomlyselectMessage1()
{
var ii = Math.floor(Message.length*Math.random())...
// ***** Modify the format of the message here. ***** //
Message1.innerHTML="<h3><em>" + Message[ii] + "</em></h3>";
}
</script>

<span id="Message1" class="fancy"></span>
<script language="JavaScript">
randomlyselectMessage1();
</script>

I've added a statement after the line
function randomlyselectMessage1()
{
--------------------------------------...
var Message1 = document.getElementById( 'Message1' );
--------------------------------------...
so that the varibale Message1 is mapped to the HTML element. As an additional information, I'd like to mention that whenever you want to access an HTML element within JavaScript, you need to use document.getElementById( 'ELEMENTID' ); where ELEMENTID is the ID or NAME assigned to that element in HTML page. This statement returns the handle to that object, after which you can manipulate properties or innerHTML of this element.

Finally, the working code is:

<script language="JavaScript">
// ***** Modify the messages here ***** //
// ***** As many messages as you can provide. ***** //
// ***** May include individually designed formatting, or url link. ***** //
var Message = new Array( "Message 1", "Message 2", "Message 3" );
function randomlyselectMessage1()
{
var Message1 = document.getElementById( 'Message1' );
var ii = Math.floor( Message.length*Math.random() );
// ***** Modify the format of the message here. ***** //
Message1.innerHTML="<h3><em>" + Message[ii] + "</em></h3>";
}
</script>

<span id="Message1" class="fancy"></span>
<script language="JavaScript">
randomlyselectMessage1();
</script>

In my personal opinion, IE has its own rules which are not standard. Firefox is far better than IE. Report It

No Idea

Tags
  General - Computers & Internet   Software   Security   Programming & Design   Facebook   Flickr   Google   MSN   MySpace
Related information
  • If computer are ones and zeros how do sounds and moving images work?

    I want to write a huge answer. I'll try to keep it short. The wonderful variety of media you are used to seeing is simply the result of very complex and numerous sets of these 0's and...

  • Need help calculating in access?

    First off, you don't need [order line id] field in your order table: in fact you don't need [order line id] at all: you can create a combined key on [order id] and [item id]. Design a ...

  • Creating and using dll files in VC++ and its advantages?

    The creation and use of DLLs with VC++ can be somewhat complicated depending on your requirements. If you create your own using the MFC wizard, it's not too bad at all. A great explanation w...

  • I need a real advice please about making my website duplicatable...?

    You should hire a web design company to do the work for you. Once they do it, you can give everyone what they need with ease.

    ...
  • How do you add a html code to a image?

    Hi! The HTML Image tag is as follows <img src="path_to_the_image.jpg" width="image_width" height="image_height" border="0" alt="image_descripti...

  • What is the purpose and functions of a network operating system?

    A network operating system (NOS) is a piece of software that controls a network and its message (e.g. packet) traffic and queues, controls access by multiple users to network resources such as file...

  • There are multiple users sharing a single Datasheert..?

    Yes you can all you do is open the workbook, then on you menu click TRACK CHANGES>HIGHLIGHT CHANGES, then on the dialogue box check the box that says "TRACK CHANGES WHILE EDITING. THIS WILL...

  • What are the main reasons that it is so hard to develop systems that are used in multiple countries?

    It's difficult to write a site in multiple languages. It's difficult to write anything in multiple languages.

    ...
  •  

    Categories--Copyright/IP Policy--Contact Webmaster