SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    Non-Member
    Join Date
    Jan 2007
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Changing only parts of a web page

    Hi I have a website which includes a flash banner and a menu apart from the regular page-dependent content. I would like to know whether it is possible to just reload certain pages of the page while leaving the flash banner movie running and also changing the menu according to the page being selected.

  2. #2
    SitePoint Evangelist priti's Avatar
    Join Date
    Aug 2006
    Location
    India
    Posts
    488
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    AJAX might be useful if a portion of web page needs to get refreshed

  3. #3
    Non-Member
    Join Date
    Oct 2008
    Location
    Banned
    Posts
    506
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just have the page regularly then Ill use youtube as an example lets say tehres a navbar type of line accross the bottom of the page and when you click different stuff new content appears. This code is untested for me. Try putting the comments in files and then this script will call the file without reloadingthe page.

    Code:
    <html>
    <head>
    <title>Untitled</title>
    <script language="javascript" type="text/javascript">
    var httprequest;
    		if (window.XMLHttpRequest)
    			httprequest = new XMLHttpRequest();
    		else if (window.ActiveXObjecct)
    			httprequest = new ActiveXObject("Microsoft.XMLHTTP");
    		else
    			alert("Your browser needs an upgrade");
    l		
    
    			function sayHello() {
    				if (httprequest.readyState == 4 || httprequest.readyState == 0) {
    					httprequest.open("GET", 'blah.html', true);
    					httprequest.onreadystatechange = handleSayHello; 
    					httprequest.send(null);
    				}			
    			}
    			function handleSayHello() {
    				if (httprequest.readyState == 4) {
    					document.getElementById('ajax_result').innerHTML = httprequest.responseText;
    				}
    			}
    			</script>
    </head>
    <body>
    <div id="banner">banner here</div>
    <div class="navbar">navbar here blah blah</div>
    <div class="flash_movie>Put the flash video here</div>
    
    		<a href="javascript:sayHello();">Hello</a><br />
    		<div id="ajax_result"></div>
    </body>
    </html>
    Theres the gist of my way of doing it. the blah.html file will contain whatever you want to reload in the page. You can call those functions multiple times with different files. Just copy and paste if you want.

    HTH

  4. #4
    Non-Member
    Join Date
    Jan 2007
    Posts
    148
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks ill try this out

  5. #5
    Non-Member
    Join Date
    Oct 2008
    Location
    Banned
    Posts
    506
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Has it helped?


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
  •