/    Sign up×
Community /Pin to ProfileBookmark

javascript does not work in netscape

Sorry if this is a dumb question, but I am new to java/javascript.

I have a page that works perfectly fine in the latest IE, but not Netscape. I’m getting the error that tabContainer is not defined. I think this may have to deal with scope of the variable or function, but am not sure at all. Here is the page: [url]http://www.relpaxchallenge.com/patient/pt_attack.htm[/url]

Any advice would be much appreciated!!

THANKS!

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@FangSep 23.2003 — Netscape is correct, it hasn't been defined.
Copy linkTweet thisAlerts:
@kdorrickauthorSep 23.2003 — Do you know how I would define it?
Copy linkTweet thisAlerts:
@dragleSep 23.2003 — Hi,

I'm guessing that you're trying to reference the div in your page with the id "tabContainter." If that is indeed the case, try using the DOM getElementById method to retrieve it, instead:
<i>
</i>GenMyTab(document.getElementById('tabContainter'))


HTH,
Copy linkTweet thisAlerts:
@kdorrickauthorSep 23.2003 — I did what you suggested and now get the same error, but, from earlier in the code... where it says:

myTab.ContainerDiv = tabContainter;

Do I need to say something about a dom element id here, too?



<script language="JavaScript">

var myTab = new Tab_obj();

var myTab2 = new Tab_obj();

function GenMyTab()

{

myTab.Name = "myTab";

myTab.Height = "300";

myTab.Width = "600";

myTab.theme = 8;

myTab.ContainerDiv = tabContainter;

myTab.SetTabDiv(1, employee, "First Attack");
myTab.SetTabDiv(2, officeAddress, "Second Attack");
myTab.SetTabDiv(3, homeAddress, "Third Attack");
myTab.GenerateControl();

}


</script>

Thanks!
Copy linkTweet thisAlerts:
@dragleSep 23.2003 — Again, I'm guessing; but it looks like what you wanted was to pass the reference to the tabContainter object to the GenMyTab function. I.E., since you're including it in your function call:
<i>
</i>GenMyTab(document.getElementById('tabContainter'))

Then you probably just meant to declare a corresponding local parameter within the function itself to "receive" it:
<i>
</i>function GenMyTab(tabContainter) {
...

Then your reference to tabContainter within GenMyTab should be fine.

Otherwise, yes; you would just refer to the div element via the same document.getElementById call mentioned earlier; i.e.,
<i>
</i> myTab.ContainerDiv = document.getElementById('tabContainter');

But in this case I don't see any need to do both. Either pass it in to the function as a parameter (which is probably what you wanted) or look it up from within the function using getElementById.

Cheers!
Copy linkTweet thisAlerts:
@kdorrickauthorSep 23.2003 — alright. I seem to be making progress. Now I get an error with the next object, which is the employee object. I suppose I must use this getelement by id statement for each object. I will try it later. I'm off to class now (a java class!!). THANK YOU so much for your help.

Please check out http://www.relpaxchallenge.com/patient/pt_attack.htm if you are interested
×

Success!

Help @kdorrick spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...