Column Dreamweaver - Framework Spry: Spry.Utils.updateContent function
By: Staff
Date: August 06, 2007
Recommended by: readers | 
Level: Advanced |
The Spry.Utils.updateContent function makes the update of the content without the necessity to be recharging the page; it makes the simulation of a iframe. To use the Spry.Utils.updateContent function and necessary to declare four arguments, being the first a id of the Div where the page goes to be loaded, as the argument is the URL of the page, the third argument is for a function to function later that the page is loaded and the room argument is for some arguments special. We will only use the two first ones.
Create a new page, it can be of any type, with the safe page we go to include the SpryData.js archive of the Frameworks Spry of tag inside Head
<script language="javascript" type="text/javascript" src="SpryData.js"></script> |
Now we go to use the Spry.Utils.updateContent function together with the function onLoad inside of tag Body, indicating which page will be loaded initially
<body onload="Spry.Utils.updateContent('id_da_div','pagina_inicial.html');"> |
We go to add links and the Spry.Utils.updateContent function together with the function onClick so that when the using click in link the Spry.Utils.updateContent function makes update of the page inside of div informed.
<a href="#" onclick="Spry.Utils.updateContent('id_da_div','pagina_1.html');"> Link 1 </a>
<a href="#" onclick="Spry.Utils.updateContent('id_da_div','pagina_2.html');"> Link 2 </a>
<a href="#" onclick="Spry.Utils.updateContent('id_da_div','pagina_3.html');"> Link 3 </a> |
Now we go to create div where the Spry.Utils.updateContent function will load the page
<div id="id_da_div"></div> |
The final code is this:
<html>
<head>
<title>Funnção Spry.Utils.updateContent</title>
<script language="javascript" type="text/javascript" src="/includes/SpryData.js"></script>
</head>
<body onload="Spry.Utils.updateContent('id_da_div','pagina_inicial.html');">
<h3>Funnção Spry.Utils.updateContent</h3>
<p>
<a href="#" onclick="Spry.Utils.updateContent('id_da_div','pagina_1.html');"> Link 1 </a>
<a href="#" onclick="Spry.Utils.updateContent('id_da_div','pagina_2.html');"> Link 2 </a>
<a href="#" onclick="Spry.Utils.updateContent('id_da_div','pagina_3.html');"> Link 3 </a></p>
<div id="id_da_div"></div>
</body>
</html> |
That would be all for this tip. More tips on working with spry options expect soon.
|