Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

HTML Forum


You are currently viewing our HTML Forum as a guest. Please register to participate.
Login



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

Reply
Changing contents of a DIV
Old 10-09-2007, 05:55 PM Changing contents of a DIV
Nathand's Avatar
Extreme Talker

Posts: 233
Location: USA
Trades: 0
Is there a way that when I click on a link it will change the contents of a div to the contents of another page on my site? I tried:

Code:
<a href="#" onclick="javascript:document.getElementById('mainbody').innerHTML=./webpage.html">webpage</a>
But it didn't work.

Thanks,
Nathan
Nathand is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 10-09-2007, 06:00 PM Re: Changing contents of a DIV
coolkbk585's Avatar
Be good this Christmas!

Latest Blog Post:
KBlog has been deativated
Posts: 642
Name: Kyle
Location: Ada, MI
Trades: 0
While it may not always be the best thing to do, you might want to use an iframe to do that. While it's not the newest technology, it would probably be the right way to go.

If you don't think so, then you should ask this again in the Javascript forum.
__________________
<?php if($Adsense_Revenue > 0): define('HAPPINES','100%'); else: define('HAPPINESS', '0%') endif; ?>
coolkbk585 is offline
Reply With Quote
View Public Profile Visit coolkbk585's homepage!
 
Old 10-10-2007, 01:43 PM Re: Changing contents of a DIV
Foundationflash's Avatar
Ultra Talker

Posts: 410
Name: Harry Burt
Location: Colchester, Essex, England
Trades: 0
PHP could do it, but it wouldn't be that efficient. Other than that, IFrames probably are the way to go. I looked into this a lot myself about a year ago, and found it was a toss-up between PHP and IFrames. Some one else might know of something though.
__________________
Foundation Flash tutorials :
Please login or register to view this content. Registration is FREE


New Dreamed Up Web Design:
Please login or register to view this content. Registration is FREE
Foundationflash is offline
Reply With Quote
View Public Profile Visit Foundationflash's homepage!
 
Old 10-10-2007, 03:55 PM Re: Changing contents of a DIV
coolkbk585's Avatar
Be good this Christmas!

Latest Blog Post:
KBlog has been deativated
Posts: 642
Name: Kyle
Location: Ada, MI
Trades: 0
You can't really request the content from another page to put into a div. You can make other HTML appear there, but it has to be in the Javascript on that page.
__________________
<?php if($Adsense_Revenue > 0): define('HAPPINES','100%'); else: define('HAPPINESS', '0%') endif; ?>
coolkbk585 is offline
Reply With Quote
View Public Profile Visit coolkbk585's homepage!
 
Old 10-10-2007, 05:49 PM Re: Changing contents of a DIV
ChipJohns's Avatar
I don't know! Do you?

Posts: 488
Name: Chip Johns
Location: Savannah Georgia
Trades: 0
Can you give us some more information about what you are trying to accomplish; with a few more specifics? The more vague the question, The less beneficial the answer. If we know more we might be able to provide alternative solutions. (but, then, again ...!)
ChipJohns is offline
Reply With Quote
View Public Profile Visit ChipJohns's homepage!
 
Old 10-11-2007, 03:22 PM Re: Changing contents of a DIV
LadynRed's Avatar
Defies a Status

Posts: 10,017
Location: Tennessee
Trades: 0
There IS away to do this !
http://www.aplus.co.yu/web-dev/inser...her-html-page/

No iframes but works like one.
__________________
Web Goddess & Web Standards Evangelist :) - Tables Be Gone !!

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE

LadynRed is offline
Reply With Quote
View Public Profile
 
Old 10-14-2007, 09:11 AM Re: Changing contents of a DIV
Foundationflash's Avatar
Ultra Talker

Posts: 410
Name: Harry Burt
Location: Colchester, Essex, England
Trades: 0
Well blow me down. I stand corrected.
__________________
Foundation Flash tutorials :
Please login or register to view this content. Registration is FREE


New Dreamed Up Web Design:
Please login or register to view this content. Registration is FREE
Foundationflash is offline
Reply With Quote
View Public Profile Visit Foundationflash's homepage!
 
Old 10-14-2007, 09:34 AM Re: Changing contents of a DIV
maxxximus's Avatar
Extreme Talker

Posts: 219
Name: Rob
Location: UK
Trades: 0
I think there is an even more seemless method with no page reload - using Ajax. The js below should be linked to or embedded directly in the head.

The function can then be called by passing the URL of the page to be loaded (Whatever.html) within the anchor tag. <a href="#" onclick="ajaxFunction('Whatever.html');return false;" >link</a>
The function will load the contents of the page into a div with an id of 'include' but you can change it to whatever.

If your prepared to use js (there are a small % of users who dont enable it) then ajax will look better.

Code:
function ajaxFunction(a)
  {
  var xmlHttp;
  try
    {
    // Firefox, Opera 8.0+, Safari
    xmlHttp=new XMLHttpRequest();
    }
  catch (e)
    {
    // Internet Explorer
    try
      {
      xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
      }
    catch (e)
      {
      try
        {
        xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
        }
      catch (e)
        {
        alert("Your browser does not support AJAX!");
        return false;
        }
      }
    }
    xmlHttp.onreadystatechange=function()
      {
      if(xmlHttp.readyState==4)
        {
       document.getElementById('include').innerHTML=xmlHttp.responseText;
        }
      }
    xmlHttp.open("GET",a,true);
    xmlHttp.send(null);
  }
  function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

Last edited by maxxximus; 10-14-2007 at 09:37 AM..
maxxximus is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Changing contents of a DIV
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 2.41030 seconds with 12 queries