www.webdeveloper.com
Results 1 to 2 of 2

Thread: How to onload?

  1. #1
    Join Date
    Aug 2012
    Posts
    2

    How to onload?

    Dear Scriptmakers,

    I have a PHP based page. I want to onload a javascript in a page but I do not know how can I do that. Let me explain:
    My page has an index.php with a slidebar ofc. I always change the content part only. The page what should contain the script is the mainpage.php. I've saved the script in a separated file and I cannot onload it. Is that any way to do that?
    This is my script:

    Code:
    <!--
    var textarray = [
    "hi",
    "hello",
    "how r u",
    "where r u" // No comma after last entry
    ];
    
    function RndText() {
    var rannum= Math.floor(Math.random()*textarray.length);
    document.getElementById('ShowText').innerHTML=textarray[rannum];
    }
    onload = function() { RndText(); }
    
    var inter = setInterval(function() { RndText(); }, 2000);
    //-->
    And I want to onload here, in the "facts" div. This area is a text contained and image bordered part of the page.

    Code:
    <div id="facts">
    	<div class="top">
    		<div class="bottom">
    			<div class="left">
    				<div class="right">
    				</div>
    			</div>
    		</div>
    	</div>
    </div>
    Any help is appreciated!

    P.s.: I do not know so much about javascript. And sorry for my English.

  2. #2
    Join Date
    Aug 2012
    Posts
    2
    Never mind, I've solved it!

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles