image
image

|


Go Back   macosx.com > Design, Media, Programming & Scripting > Design & Media

Reply
 
Thread Tools
  #1  
Old February 24th, 2005, 12:51 AM
Mac Metal Head
 
Join Date: Nov 2003
Posts: 821
Thanks: 0
Thanked 0 Times in 0 Posts
HateEternal is on a distinguished road
Loading external pages/seperate pages in a div

Is there anyway, through javascript and the DOM (or any other way) to load any specified html file into a div, so in a way the div is used like a frame would be?

I am just trying to find a way to replace frames with divs alone. I know how to set a div's HTML through javascript but I don't know how to load any external html. I have been searching and have not yet found a way. I expect that if there is a way, it is ugly and not worth it.

Let me know if you have a way to do it, its probably more of geek wanting to know how something works more than practical use.
Reply With Quote
  #2  
Old February 24th, 2005, 03:58 AM
mrfluffy's Avatar
OmniWeb Convert
 
Join Date: Dec 2001
Location: Hants UK
Posts: 346
Thanks: 0
Thanked 0 Times in 0 Posts
mrfluffy is on a distinguished road
xmlhttprequest can load html (porbably not a whole page though cos there'd be 2 body/head tags) into a div, Apple have a tutorial - http://developer.apple.com/internet/...mlhttpreq.html

and I'm working on a web-based Delicious Library which uses it - http://www.dottom.co.uk/library/ (really not finished)
__________________
PowerBook G4 1.25Ghz, 15", 1GB, 80GB,SuperDrive, 10.4
MacMini, 1.25Ghz G4, 256MB (will be upgraded), 80GB, Combo Drive, 10.4
20GB iPod (4G)
eMate 300, Newton OS 2.1, Bluetooth
Newton MessagePad 2000, Newton OS 2.1, WiFi, Bluetooth
NeXT Turbo Colour, NeXTStep 3.3
TomPhippen.com
dogtanian.net
Reply With Quote
  #3  
Old February 24th, 2005, 09:33 AM
andehlu's Avatar
this modern love
 
Join Date: Feb 2004
Location: torontoCANADA
Posts: 244
Thanks: 0
Thanked 0 Times in 0 Posts
andehlu is on a distinguished road
i wish this could be done easilly. The only way is to have an iframe within the div tag thgen target that iframe....
__________________
site | blog | garageband experiments
Reply With Quote
  #4  
Old February 25th, 2005, 09:36 AM
Mac Metal Head
 
Join Date: Nov 2003
Posts: 821
Thanks: 0
Thanked 0 Times in 0 Posts
HateEternal is on a distinguished road
Quote:
Originally Posted by mrfluffy
xmlhttprequest can load html (porbably not a whole page though cos there'd be 2 body/head tags) into a div, Apple have a tutorial - http://developer.apple.com/internet/...mlhttpreq.html

and I'm working on a web-based Delicious Library which uses it - http://www.dottom.co.uk/library/ (really not finished)
cool, I'll give it a try. it shouldn't be a problem with the 2 body/head tags. Worst case I'll just leave the head and body tags off my dynamic content.
Reply With Quote
  #5  
Old February 25th, 2005, 11:15 AM
Cat's Avatar
Cat Cat is offline
Registered User
 
Join Date: Jan 2003
Location: @ my Mac
Posts: 1,972
Thanks: 0
Thanked 0 Times in 0 Posts
Cat is on a distinguished road
Perhaps this is a stupid question, but is there any reason not to use PHP? It may depend on what exactly you are trying to achive and PHP may not be the best solution, but anyway ...
Code:
<?php include "filename"; ?>
__________________
This is not a signature (but I could be wrong).
15" MacBook Pro C2D@2.4 GHz | 2 GB RAM | Mac OS 10.5.4 |
Website | LinkedIn | Publications
GP/O d-(+)@ s: a->? C++(+++) U* P+ L+>++ !E---- W+++ N o? K? w--- O? M++ V? PS+++ PE-- Y+ PGP t 5? X- R !tv b++++ DI+(++)@ D+(++) G++(+++) e+++$>++++$$ h--->---- r+++ y++++@
Reply With Quote
  #6  
Old February 25th, 2005, 02:44 PM
Mac Metal Head
 
Join Date: Nov 2003
Posts: 821
Thanks: 0
Thanked 0 Times in 0 Posts
HateEternal is on a distinguished road
Quote:
Originally Posted by Cat
Perhaps this is a stupid question, but is there any reason not to use PHP? It may depend on what exactly you are trying to achive and PHP may not be the best solution, but anyway ...
Code:
<?php include "filename"; ?>
Ok, so you know how iframes work? So say I made a website with a content frame and a navigation div. When I click on a link in the nav it opens the new page in the iframe. I want to be able to do the same thing but only using divs. You can make scrollable divs, which is not a problem, but I don't know how to load html from a separate file in the div if a link is clicked. So it would be functionally the same as using an iframe... but not using an iframe. Biggest benefit is that I can make pages for my class that validate strict and still have the same functionality.
Reply With Quote
  #7  
Old February 25th, 2005, 03:40 PM
mdnky's Avatar
[Bobs/Prog/Design:~] mod%
 
Join Date: Jul 2001
Location: Baton Rouge, LA - USA
Posts: 2,638
Thanks: 0
Thanked 0 Times in 0 Posts
mdnky is on a distinguished road
Quote:
Originally Posted by HateEternal
Ok, so you know how iframes work? So say I made a website with a content frame and a navigation div. When I click on a link in the nav it opens the new page in the iframe. I want to be able to do the same thing but only using divs. You can make scrollable divs, which is not a problem, but I don't know how to load html from a separate file in the div if a link is clicked. So it would be functionally the same as using an iframe... but not using an iframe.
You'd have to use a few different methods combined for it to work. The PHP include for the content, and JS for the links to know which to use.

You're probably better off in the long run keeping it more 'traditional' as separate pages. That'll go better towards standards compliance and accessibility/usability.
__________________
.
| mdnky@macosx.com | My Homepage | My Music | Restore the Pledge | MacOSX.com Widget |

• MacBook Pro Core2Duo 2.33GHz 15", 2GB DDR2 RAM, 120GB, DL Superdrive, OS X 10.5,
• Apple 23" Cinema HD Display, Apple Slim-Stainless Keyboard, Logitech Optical Scroll Mouse
• iPhone 8GB, iPod Photo 30GB, Nikon D50, Nikon L6, Epson 3490, Epson R1800, HP LaserJet 1200
• LaCie 500GB d2 Quadra, LaCie 160GB d2 FW, harman/kardon SoundSticks II, Mighty Mouse, iSight

Reply With Quote
  #8  
Old February 25th, 2005, 04:38 PM
andehlu's Avatar
this modern love
 
Join Date: Feb 2004
Location: torontoCANADA
Posts: 244
Thanks: 0
Thanked 0 Times in 0 Posts
andehlu is on a distinguished road
i think he wants to make divs load external documents without complete page reload, is this right hateeternal? If so, this cannot be done, you need to have an iframe the dimensions of your div and target the iframe in the nav. You will be able to still hide and show the div's with JS. But I totally agree there should be something like <div src="your_externaldoc.php">
__________________
site | blog | garageband experiments
Reply With Quote
Reply

Thread Tools

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
Forum Jump


All times are GMT -5. The time now is 01:47 AM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.