/    Sign up×
Community /Pin to ProfileBookmark

I am new to Javascript (JS). I have two questions after reading JS book.
1.
if I write:
<script>
location=”http://www.google.com“;
setInterval(m,300);

function m()
{
alert(“Hello”);
}
</script>
, the browser executes m() for a short while before the google page is fully loaded. Does this mean the browser listens to the instructions from the JS interpretor? The situation is like an employee(browser) and an employer(interpretor)?
2.
If I set
document.bgColor=”blue”;,
the browser immediately changes the background color to blue.(before the control flow reaches </script>).
Questions is: generally in what situation, the browser adopts the change immediately? I think if I add a new property of a window object, say
window.newproperty=”anything”;, the browser refreshes the contents is a waste of resourses.

to post a comment
JavaScript

1 Comments(s)

Copy linkTweet thisAlerts:
@nazzySep 01.2009 — browsers adopt the change immediately except for I.E. explorer loads the document first before executing the js code. browsers read the entire js code written in that particular page before opening a new window or new page and by loading a new page, those codes are no longer read.

all the properties added to your window object will be read before the new page or new window loads, the new page will not inherit the previous codes except of course if you pass variables to that new page
×

Success!

Help @Sup 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 6.17,
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: @nearjob,
tipped: article
amount: 1000 SATS,

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

tipper: @meenaratha,
tipped: article
amount: 1000 SATS,
)...