View Full Version : [Q] How to supply the source file for the DIV tag???

01-30-2005, 06:07 PM
Howdy... :)

I was reading this article...


It looks good... I was wondering if I could specify the external file for the content...

For example, it says...
<div id="header">Header Section</div>
<div id="leftcol">Left Section</div>
<div id="content">Content Section</div>
<div id="rightcol">Left Section</div>
<div id="footer">Footer Section</div>

and I want it to be something like this(of course, not a valid syntax...)
<div id="header">header.html</div>
<div id="leftcol">navigation.html</div>
<div id="content">content.html</div>
<div id="rightcol">extra.html</div>
<div id="footer">footer.html</div>

Thanks... ;)

01-30-2005, 08:28 PM
I'm no expert at things like this, but i think that you need to use php for something like that... At least all the places where i can think of html being reused it seems to be php.

02-01-2005, 02:14 AM
Found it... DIV accepts source file the same way iframe does... :)

div src="somefile.html"></div>

02-01-2005, 04:25 PM
Thanks for the article link CyanBlue. Gave me the answer to a problem i was having as well.

02-01-2005, 06:33 PM
Hm... NOW... Does anybody know how I can refresh the content of one DIV from another???

02-01-2005, 10:46 PM
I am creating something like that right now. I am going to use the onSelect function to tell a javascript to run a function that turns my other div visible.

In my case I have a select statement that when a certain item is selected a div is turned visible for more options.

I'll have something tommorrow if you dont find a solution.

02-01-2005, 10:53 PM
Here is abit more detailed version of that question if anybody can help me... :D

I have two DIV frames...
<div id="leftcol"><?php include("navL.html"); ?></div>
<div id="content"><?php include("content.php"); ?></div>
and in the leftcol DIV frame, I have navL.html file loaded... (If you know of better way of doing it, please let me know... ;))

This is the content of the navL.html file...
<script type="text/javascript">

function load(arg)
document.getElementByID("content").src = arg + ".html";


<a href="#" onClick="javascript:load('test1');">test1</a>
<a href="#" onClick="javascript:load('test2');">test2</a>

In there I have two links which I want to use to update the content DIV frame with either test1.html or test2.html depending on the link that is clicked, but somehow it is not working... :(

Does anybody know how I can solve this problem???

Thank you very much... :)

08-03-2007, 06:21 AM
<div src="fn.htm" ></div>
This is not wokring for me. Could somebody suggest me.

Best Regards

12-11-2007, 12:50 PM
Reply for Sreeni Ques..
It Wont work bcoz div doesn't an attrib called src..
Instead you can make use of the javascript+iframe to do the magic for you..

May be this could answer your question :) :) :)
================================================== =======================
<script type="text/javascript">
function setMyDiv(userFile)
document.getElementById("myDiv").innerHTML = "<iframe src='"+userFile+"' width=800 height=300 frameborder=0 scrolling=yes>";
<body onLoad="setMyDiv('http://www.altavista.com/')">
<div id="myDiv">
Default content for Div
<br />
<br />
<input type="button" onClick="setMyDiv('http://www.google.com/')" value="Google" />
<input type="button" onClick="setMyDiv('http://www.altavista.com/')" value="Altavista" />
================================================== =======================