Question 1: I need to open a html file with one parameter (string).
The following code is just demo of large code. I made it to let you understand my requirement. Here is my code....
main.html
<!DOCTYPE html>
<html>
<body>
<p>Click on the sun or on one of the planets :</p>
<img src="http://www.w3schools.com/html/planets.gif" alt="Planets" usemap="#planetmap" style="width:145px;height:126px;">
<map name="planetmap">
<area shape="rect" coords="0,0,82,126" alt="Sun" href="mountain.html">
<area shape="circle" coords="90,58,3" alt="Mercury" href="mountain.html">
<area shape="circle" coords="124,58,8" alt="Venus" href="mountain.html">
</map>
</body>
</html>
mountain
<h2>Spectacular Mountain</h2>
<img src="http://www.w3schools.com/html/pic_mountain.jpg" alt="Mountain View" style="width:304px;height:228px;">
<p id="demo"></p>
<script language="javascript" type="text/javascript">
function myFunction(arg) {
this.name = arg;
}
var x = new myFunction(name) /*HERE NAME SHOULD BE Sun/Mercury/Venus clicked by user*/
document.getElementById("demo").innerHTML = x.name;
</script>
<input type="button" value="Back !" onclick="history.back(-1)" />
</body>
</html>
Here this.name = alt; How can I get "alt (Sun/Mercury/Venus)"clicked by user.
Question 2: IS there any better way instead of the following:
<input type="button" value="Back !" onclick="history.back(-1)" />