Consider the following code
Code:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<title> </title>
<style type="text/css">
</style>
<script type="text/javascript">
window.onload = function(){
if(location.href.indexOf('layer=') != -1)
if(document.getElementById(location.href.split('layer=')[1]))
document.getElementById(location.href.split('layer=')[1]).style.display = 'block';
}
</script>
</head>
<body>
<div id="one" style="display:none;">This is the first layer </div>
<div id="two" style="display:none;">This is the second layer</div>
<div id="three" style="display:none;">This is the third layer</div>
</body>
</html>
After saving the page open the browser and load the page in the following manner, assume that the file name is test.htm
Code:
file:///C:/Documents%20and%20Settings/Code/Desktop/test.htm?layer=two
We pass a parameter in to the page whose name is layer and value is two. This tells my JS function to display the div element whose ID is two. In other words you are passing the ID of the element which you want to display. If the page contains any element with the mentioned ID then it will be displayed - assuming that the element with the ID is hidden.
Like this if you want to load the element whose ID is three use the following url
Code:
file:///C:/Documents%20and%20Settings/Code/Desktop/test.htm?layer=two
Note that the file save location will change based on your storage location.
Bookmarks