4
Contributors
4
Replies
8
Views
5 Years
Discussion Span
Last Post by pzuurveen
0

No you cannot "set .js page's scope to specific <div>".

In client-side javascript the global scope is always window. This cannot be changed.

In addition to the global scope, other scopes may also exist at runtime, as determined by the structures within the code that you have written, particularly functions.

Javascript can be, and more often than not is, written to address specific DOM elements, including divs, typically to read/write their contents and/or change their appearance.

JavaScript objects/variables can also be arbitrarily assigned to DOM elements. This is a "namespacing" technique and not "scope" in the traditional computer lanuage sense. This last point has caused me to think hard and I would be pleased to know other people's opinion.

Airshow

0

The terminology used is not exact, but we could call it a contextual script element, or something.
Such thing was possible in Explorer.

<div id=div1> div1 content </div>
<script for=div1 event=onlouseover src=div1.js></script>

But it becomes expensive, I never used it..

0

ofcourse you can use a diferent eventhander on every div
<div id="div1" onmouseover="handeldiv1()" >

Edited by pzuurveen: still not used to the new code tags

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.