473,835 Members | 1,858 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Javascript outside of <HTML> tags

Hello.

I am attempting to write a "scraper" to download information from a
commercial web site. Oddly enough, they don't want to make this easy for me!
Their pages include plenty of Javascript, and more than a few redirects.

One that is stumping me is a small page that includes a document object
redirect in the <body> tag's onload() event. Like this:

<body
onload='javascr ipt:document.lo cation.replace(http://www.new_domain_goes_here.org);

The redirect does not work.

There are two <script> blocks located after the closing </HTML> tag. The
first block sets some variables. The second block inserts a .JS file
containing some _very_ convoluted Javascript code which uses some of the
variables from the first script block.

My question is:

Since this scripting is located outside of the HTML document, would the
browser run these scripts before the document onload() event is executed? If
this is the case, then perhaps this code is overriding the onload() event or
rewriting it in some way.

Thanks
-Mark

Jun 29 '06 #1
4 3952
Mark G. wrote:
I am attempting to write a "scraper" to download information from a
commercial web site. Oddly enough, they don't want to make this
easy for me!
That is not odd. Why let you take something when they could be charging
you for it?
Their pages include plenty of Javascript, and more than a few
redirects.

One that is stumping me is a small page that includes a document
object redirect in the <body> tag's onload() event. Like this:

<body
onload='javascr ipt:document.lo cation.replace(http://www.new_domain_goes_here.org);

The redirect does not work.
No it would not work as there are not quotes around the URL. So it is a
syntax error and will never be executted.

<snip> Since this scripting is located outside of the HTML document,
would the browser run these scripts before the document onload()
event is executed?
Browsers would be in their rights to ignore such scripts, but in
reality they mostly error-correct them into contents of the BODY
element.
If this is the case, then perhaps this code is overriding the onload()
event or rewriting it in some way.


No, the syntax error in the onload code is more likely the problem.

Richard.

Jun 29 '06 #2

"Richard Cornford" <Ri*****@litote s.demon.co.uk> wrote:

That is not odd. Why let you take something when they could be charging
you for it?
I was being facetious, of course. I do subscribe to the site.
I just want to automate what would otherwise require a
great deal of mousing around.
No it would not work as there are not quotes around the URL.
The actual URL has quotes around it. This was just my error
in typing my original post.

No, the syntax error in the onload code is more likely the problem.


Ok, thanks. I will investigate further.

-Mark
Jun 29 '06 #3
"Mark G." <no****@thanksa nyway.org> wrote in news:1151600874 .103509
@bubbleator.dri zzle.com:
My question is:

Since this scripting is located outside of the HTML document, would the
browser run these scripts before the document onload() event is

executed?

You could have answered your own question by writing a simple test page:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>JS outside html</title>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-
8859-1">
</head>

<body onload="alert(' loaded');">

Text in body.
</body>
</html>

<SCRIPT LANGUAGE="JavaS cript" TYPE="text/javascript">
<!--
alert('after html ended');

//-->
</SCRIPT>
Jun 29 '06 #4
"Jim Land" <RrrrFfffTttt(N O)@(SPAM)hotmai l.com> wrote:

You could have answered your own question by writing a simple test page:


But then I wouldn't have had an opportunity to thank you!

-Mark
Jun 29 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
2271
by: Madhav | last post by:
I have the following statements in my script. ---------------------------------------------------------- textToWrite = "<HTML> \n" + "<HEAD> \n" + "<TITLE>Calendar</TITLE> \n" + "<SCRIPT LANGUAGE=\"JavaScript1.2\"SRC=\"popWin.js\">"+ "</SCRIPT> \n" + "</HEAD> \n" + "<BODY> \n" ; textToWrite += "<\BODY>\n" +
18
3775
by: Shannon Jacobs | last post by:
Trying to solve this with a regex approach rather than the programmatic approach of counting up and down the levels. I have a fairly complicated HTML page that I want to simplify. I've been able to mung most of it using several regular expressions, but I've become stuck at this point. I can't figure out how to grab only the <tr> tags that are associated with tables that are two levels deep. I feel like I got close, but it seems that...
30
3923
by: Toni Mcintyre | last post by:
i'm having 2 problems with the http://validator.w3.org 1. if i have: <meta http-equiv="Content-Script-Type" content="text/javascript"> then why do i need <script type=text/javascript> everywhere??? i'm writing most of my code by hand, so this is a lot of extra typing or global search and replace later 2. the other problem is with my include files: i usually <script src="foo.js"></script>
9
3709
by: Wayfarer | last post by:
Hi, I've been developing in Firebird, so I didn't notice this until today. When I use the <q> tag, IE 6 doesn't put quotes around the quotation. I tried specifically doing it in a stylesheet: q:before { content: open-quote; } q:after { content: close-quote; } but it didn't work.
7
2755
by: Rocky Moore | last post by:
I have a web site called HintsAndTips.com. On this site people post tips using a very simply webform with a multi line TextBox for inputing the tip text. This text is encode to HTML so that no tags will remain making the page safe (I have to convert the linefeeds to <BR>s because the Server.EncodeHTML does not do that it seems). The problem is that users can use a special tag when editing the top to specify an area of the tip that will...
1
393
by: MBO | last post by:
Hello NG, I'm writing a control that needs to put a clientside javascript between the <HEAD> Tags of a webpage where it is placed on. I've seen from other threads in this NG, that one solution is to assign a runat="server" and an id="myheader" attribute to the HEAD-Tag. On the code behind I've defined a variable Protected myHeader As System.Web.UI.HtmlControls.HtmlGenericControl to access the HEAD tag. My Problem is, that everytime...
2
2105
by: taras.di | last post by:
Hi everyone, Is it possible to place javascript outside of <html> tags? I'm trying it on mozilla atm, and it seems to be working, but I was more worried about the older browsers. Cheers Taras
6
19621
by: joseph.lindley | last post by:
Forgive me for I am a bit of a web-dev novice - but I'm not doing too bad. I'm currently working with a bit of javascript to dynamically add <option>s into a select box. My code currently works fine in Internet Explorer, however in Firefox the dropdown only displays the first option in the list, and when clicked the other values aren't displayed. Here is the code;
3
2050
by: Swaine77 | last post by:
:confused: I've asked my professor about this one a couple of times in email and she gave me some tips but I still can't nail this one down. Our book only gives one example of using .innerHTML and it's not very relevant to this problem so I want to ask you JS proz out there. We're supposed to loop through the document.all collection and find all the <p> tags and enclose them in <strong> tags. I'm pretty sure I've got most of the...
0
9652
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10812
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10561
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9346
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7766
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6966
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5804
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4434
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3089
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.