I want to dynamically add a hidden <div> </div> to a document when loading my page. It is kind of a generic scratch pad into which I can load messages and data I may want to display to the user. I want to do it this way so I can place it in my base .js file for inclusion in all apps I write without having to reinvent the wheel each time.
My problem is this; the <body> tag does not seem to pass the "id" value but rather the name of the application. I am using fireFox.
In this example the obj parameter becomes "appName.ex e". And when I try to use the id in the function addScratchPad(o bj) like this
var cThisApp = obj.id
I get an "undefined" error.
I want to use the id value to insert the scratchPad into the document like this
document.getEle mentById(cThisA pp).innerHTML = "<div>.... other conten.. </div>
Here is my code:
function in the .js file
My problem is this; the <body> tag does not seem to pass the "id" value but rather the name of the application. I am using fireFox.
In this example the obj parameter becomes "appName.ex e". And when I try to use the id in the function addScratchPad(o bj) like this
var cThisApp = obj.id
I get an "undefined" error.
I want to use the id value to insert the scratchPad into the document like this
document.getEle mentById(cThisA pp).innerHTML = "<div>.... other conten.. </div>
Here is my code:
Code:
<HEAD>
<TITLE> dailyTimeReview </TITLE>
<script type="text/javascript" language="JavaScript" src="Navigation.js"></script>
<script language="JavaScript">
<!--])
function myStartUp(obj)
{
addScratchPad(obj);
aDepts = cMyDepts.split('~');
}
//-->
</script>
</HEAD>
<body
id ="testForm"
onLoad = "myStartUp(this);"
>
Code:
function addScratchPad(obj)
{
//this next line fails
alert(obj.id);
}
Comment