473,659 Members | 2,683 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Inline script works - but fails when included from .js file - why?


Folks,

I've found a nice menu piece of javascript that works fine when the code is
included entirely inside the html page. However, when I place the
javascript code outside, in its own ".js" type file, it doesn't execute.
IE6 reports an error "Object expected" line 30, char 1, code 0. This is the
BODY tag which I've pasted below (with carriage returns to make it easier to
read). I cannot understand as to how this line could be problematic though
since its the exact same in my 'inline' script which works.

<BODY marginwidth="0"
marginheight="0 "
style="margin: 0"
onLoad="writeMe nus()"
onResize="if (isNS4) nsResizeHandler ()">

Why does it fail? How do I fix it? If it helps further, I have the code
uploaded and available at:

This is where the menu is 'inline'
http://www.wiredwords.net/a.htm

This is where the menu is included using <script src=></script> tags
http://www.wiredwords.net/b.htm

Thanks in advance,
Randell D.
Jul 20 '05 #1
7 3871

"Randell D." <yo************ **************@ yahoo.com> wrote in message
news:XeJmb.1829 69$pl3.164559@p d7tw3no...

This is where the menu is included using <script src=></script> tags
http://www.wiredwords.net/b.htm


Change this:

<script src=/b.js></script>

To this:

<script src="b.js">
</script>

That carriage return seems to help for some browsers. Also get your
quoting right. And, unlike me, check to make sure you are actually
pointing to teh file's correct location.
--
--
Fabian
Visit my website often and for long periods!
http://www.lajzar.co.uk
Jul 20 '05 #2

"Fabian" <la****@hotmail .com> wrote in message
news:bn******** *****@ID-174912.news.uni-berlin.de...

"Randell D." <yo************ **************@ yahoo.com> wrote in message
news:XeJmb.1829 69$pl3.164559@p d7tw3no...

This is where the menu is included using <script src=></script> tags
http://www.wiredwords.net/b.htm


Change this:

<script src=/b.js></script>

To this:

<script src="b.js">
</script>

That carriage return seems to help for some browsers. Also get your
quoting right. And, unlike me, check to make sure you are actually
pointing to teh file's correct location.
--
--
Fabian
Visit my website often and for long periods!
http://www.lajzar.co.uk


Thanks for the quick response but... Nope... that didn't do it - IE now
reports the error on line 31 (since I placed a carriage return in like you
suggested) - this is the BODY tag. I also cleared my cache, re-tried and
rechecked my cache... The correct "b.js" file is loaded (and visable in my
cache)... But to cover myself, I actually said

<script src="http://www.wiredwords. net/b.js">
</script>

(thus I specified the full server path in the source).

Any other ideas? Scripts are still available on
http://www.wiredwords.net/a.htm (this works)
http://www.wiredwords.net/b.htm (this fails)

Also FYI... for some reason my Outlook Express asked me to download Japanese
character set to read your post... dunno if you knew this or if you have
some character that you have included in your signature....

thanks
Jul 20 '05 #3
> I've found a nice menu piece of javascript that works fine when the code
is
included entirely inside the html page. However, when I place the
javascript code outside, in its own ".js" type file, it doesn't execute.


You have left the <script ...> and </script> lines in your ".js" file. They
are HTML constructs and don't belong there. You just need the JavaScript.
Jul 20 '05 #4

"Randell D." hu kiteb
Thanks for the quick response but... Nope... that didn't do it - IE now reports the error on line 31 (since I placed a carriage return in like you suggested) - this is the BODY tag. I also cleared my cache, re-tried and rechecked my cache... The correct "b.js" file is loaded (and visable in my cache)... But to cover myself, I actually said

<script src="http://www.wiredwords. net/b.js">
</script>
Unless it is actually on a different server, specifying teh full server
path is bad form, as some browsers won't cache properly that way. I
concur with Graham - you shouldnt have those <script> tags or <!--html
comment--> tags in the .js file.
Also FYI... for some reason my Outlook Express asked me to download Japanese character set to read your post... dunno if you knew this or if you have some character that you have included in your signature....


I think your computer is getting lonely, and wants a few more fonts to
play with. DOwnload or not, you choose. I believe there is even an
option on the lines of dont ask me this again. I know I can change the
defaults, but msoe is so tightly integrated that it will cause all kinds
of not fun problems if I mess with that setting.

--
--
Fabian
Visit my website often and for long periods!
http://www.lajzar.co.uk

Jul 20 '05 #5
"Randell D." <yo************ **************@ yahoo.com> writes:
<script src="http://www.wiredwords. net/b.js">
</script>


Your Javascript file contains non-javascript text:
---
<SCRIPT LANGUAGE="JavaS cript">
<!-- Original: Angus Turnbull -->
<!-- Web Site: http://gusnz.cjb.net -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
---
and
---
</script>
---
This is HTML, not Javascript.

The script HTML tag is used to include the content (which should be
Javascript) in an HTML document. When you have a stand-alone Jasascript
file, all of the content must be Javascript.

While browsers might allow HTML comments in Javascript, it is not
correct. Use Javascript comments instead.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 20 '05 #6

"Lasse Reichstein Nielsen" <lr*@hotpop.com > wrote in message
news:n0******** **@hotpop.com.. .
"Randell D." <yo************ **************@ yahoo.com> writes:
<script src="http://www.wiredwords. net/b.js">
</script>
Your Javascript file contains non-javascript text:
---
<SCRIPT LANGUAGE="JavaS cript">
<!-- Original: Angus Turnbull -->
<!-- Web Site: http://gusnz.cjb.net -->

<!-- This script and many more are available free online at -->
<!-- The JavaScript Source!! http://javascript.internet.com -->

<!-- Begin
---
and
---
</script>
---
This is HTML, not Javascript.

The script HTML tag is used to include the content (which should be
Javascript) in an HTML document. When you have a stand-alone Jasascript
file, all of the content must be Javascript.

While browsers might allow HTML comments in Javascript, it is not
correct. Use Javascript comments instead.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors:

<URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html> 'Faith without judgement merely degrades the spirit divine.'

Many thanks for that!
Jul 20 '05 #7

"Graham J" <in************ ***@orangebucke t.co.uk> wrote in message
news:bn******** *****@ID-203032.news.uni-berlin.de...
I've found a nice menu piece of javascript that works fine when the code is
included entirely inside the html page. However, when I place the
javascript code outside, in its own ".js" type file, it doesn't execute.


You have left the <script ...> and </script> lines in your ".js" file.

They are HTML constructs and don't belong there. You just need the JavaScript.


Many thanks for that!
Jul 20 '05 #8

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

Similar topics

2
2165
by: dot | last post by:
I'm trying to use some code I found here - http://javascript.internet.com/navigation/click-to-expand-menu.html When I open this page in my browser (Firefox at the moment), the click-expand menu works fine. If I do show->page source, copy the source to a local file, then open the file in my browser, the menus are expanded and there are no click buttons. Likewise, I can't copy the code given on the web page and make it work either.
3
2856
by: Jon Maz | last post by:
Hi All, I've just noticed that there seem to be two ways of setting up a global.asax file. At http://www.csharphelp.com/archives/archive206.html the global.asax example has Application_Start etc within <script runat="server"> ... </script> tags, whereas VS.Net creates a global.asax.cs file that is presumably pre-compiled like a .aspx.cs file.
1
3242
by: Kevin Potter | last post by:
We have an application that has been running on IIS4 and IIS5 for quite some time, without problem We're now migrating to IIS6 (windows/2003), and have run into a what might? be a Javascipt problem/question... The snippet of code in question is: <script language="JavaScript"><!-- document.write("<script src='/fp/"+includename+"'></script>"); // -->></script>
3
8311
by: Steve Yerkes | last post by:
There seems to be way too much confusion over how to set focus on the a field using a field validator. I looked all over the web and found people trying to do this, but not getting anywhere. There are a couple of people selling components... but that is not really an option for me... So, I took the plunge and modified the "WebUIValidation.js" file to make it happen... After tracing through file, I figure it out. It was actually pretty...
6
3418
by: Anders M | last post by:
I'm trying to use Inline-code to call Page_load, Page_Init or Page_PreRender methods. I've also got a code behind c#-file. I can define inline methods for buttons and so on...that works fine. But when I try to call Page_load, Page_Init or Page_PreRender methods it doesn't work. Non of the methods get's triggered !?
12
7768
by: JMB | last post by:
Hello, I was wondering if anyone knew of any projects extending the inline upload progress bar to utilize an inpage image uploader with bar, without having to refresh or go to a seperate page, nor opening a second box for display of the progress bar. I had been using the MegaUpload that was adapted from Raditha's script at http://www.raditha.com/upload.php . The MegaUpload script I have been using takes the progress bar inpage,...
7
16100
by: Wu Shaohua | last post by:
Hi Guys, 1. As we know usually we should not define a constructor as inline. I also learned if we define a member function inside the class this member function will be automatically be inline'ed. My question is: If I define a constructor (including its body) or another large member function inside the class, the constructor or the member function is inline or not? why? 2. I learned that if the member function is big we should not...
9
20889
by: 8anos | last post by:
Hello, I am new at the community and newbie at programming :) As you may know rapidshare provides a perl script for linux, to upload files at their servers. You can find the original scripts at rapidshare news : http://images.rapidshare.com/software/rsapi.pl If you test it you will see that you can upload one file at time. I try to modify it in that way that script can read a text file with the names of the files i want to...
1
47445
KevinADC
by: KevinADC | last post by:
Note: You may skip to the end of the article if all you want is the perl code. Introduction Many websites have a form or a link you can use to download a file. You click a form button or click on a link and after a moment or two a file download dialog box pops-up in your web browser and prompts you for some instructions, such as “open” or “save“. I’m going to show you how to do that using a perl script. What You Need Any recent...
0
8427
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8332
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
8746
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8525
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
8627
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6179
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
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1737
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.