PDA

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


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

I was reading this article...

http://www.devarticles.com/c/a/Web-Style-Sheets/DIV-Based-Layout-with-CSS/6/

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... ;)

Laguana
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.

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

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

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

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

Gibberish
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.

CyanBlue
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...
<body>
<div id="leftcol"><?php include("navL.html"); ?></div>
<div id="content"><?php include("content.php"); ?></div>
</body>
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)
{
alert(arg);
document.getElementByID("content").src = arg + ".html";
}

//-->
</script>

<a href="#" onClick="javascript:load('test1');">test1</a>
<BR>
<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... :)

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

Best Regards
Sreeni

mmkader85
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 :) :) :)
================================================== =======================
<html>
<head>
<script type="text/javascript">
function setMyDiv(userFile)
{
document.getElementById("myDiv").innerHTML = "<iframe src='"+userFile+"' width=800 height=300 frameborder=0 scrolling=yes>";
}
</script>
</head>
<body onLoad="setMyDiv('http://www.altavista.com/')">
<div id="myDiv">
Default content for Div
</div>
<br />
<br />
<form>
<input type="button" onClick="setMyDiv('http://www.google.com/')" value="Google" />
<input type="button" onClick="setMyDiv('http://www.altavista.com/')" value="Altavista" />
</form>
</body>
</html>
================================================== =======================