Hiding JavaScript code in the HTML

F

Fred

BlankCould some kind person take a look at the source page of http://www.all-inclusive-hotels.co.uk/ and show me how to hide the long code for both the drop down menu's. I know I can save the code to say mysripts-menu1.js but I'm not sure how much of the code I have to "hide" and what I place in the <body> to call it up on loading. Any help would be much appreciated. Fred
 
T

Thomas A. Rowe

The code is not hidden when you place it in a external .js file, actually it make it easier to
"borrow" since it is in a single file download to the user's browser's cache folder.

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
==============================================
If you feel your current issue is a results of installing
a Service Pack or security update, please contact
Microsoft Product Support Services:
http://support.microsoft.com
If the problem can be shown to have been caused by a
security update, then there is usually no charge for the call.
==============================================

BlankCould some kind person take a look at the source page of http://www.all-inclusive-hotels.co.uk/
and show me how to hide the long code for both the drop down menu's. I know I can save the code to
say mysripts-menu1.js but I'm not sure how much of the code I have to "hide" and what I place in the
<body> to call it up on loading. Any help would be much appreciated. Fred
 
F

Fred

Hi Thomas,

Sorry for using the wrong terminology. I should have said hidden from the
search engine spider when the page is crawled. Let me rephrase my question.
I assume that this is all that is placed in the <head> of the page or can
this also 'hidden' <script LANGUAGE="JavaScript"><!--function load(form)
{var url = form.list.options[form.list.selectedIndex].value;if (url != "")
location.href = url; return false;}// --></script> Note that all spacing has
been removed.

And how much of the code in the <body> between <form NAME="menu1"> and
</select> </form>
do I save to a ( plain text file say using notepad) which I would call
myscript-menu1.js and save to my root and what text do I place in the <body>
where I want the menu to appear. Fred
 
T

Thomas A. Rowe

Ok, that is a good question, and I don't know the answer.

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
==============================================
If you feel your current issue is a results of installing
a Service Pack or security update, please contact
Microsoft Product Support Services:
http://support.microsoft.com
If the problem can be shown to have been caused by a
security update, then there is usually no charge for the call.
==============================================

Fred said:
Hi Thomas,

Sorry for using the wrong terminology. I should have said hidden from the search engine spider
when the page is crawled. Let me rephrase my question. I assume that this is all that is placed in
the <head> of the page or can this also 'hidden' <script LANGUAGE="JavaScript"><!--function
load(form) {var url = form.list.options[form.list.selectedIndex].value;if (url != "")
location.href = url; return false;}// --></script> Note that all spacing has been removed.

And how much of the code in the <body> between <form NAME="menu1"> and </select> </form>
do I save to a ( plain text file say using notepad) which I would call myscript-menu1.js and save
to my root and what text do I place in the <body> where I want the menu to appear. Fred


Thomas A. Rowe said:
The code is not hidden when you place it in a external .js file, actually it make it easier to
"borrow" since it is in a single file download to the user's browser's cache folder.

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
==============================================
If you feel your current issue is a results of installing
a Service Pack or security update, please contact
Microsoft Product Support Services:
http://support.microsoft.com
If the problem can be shown to have been caused by a
security update, then there is usually no charge for the call.
==============================================

BlankCould some kind person take a look at the source page of
http://www.all-inclusive-hotels.co.uk/ and show me how to hide the long code for both the drop
down menu's. I know I can save the code to say mysripts-menu1.js but I'm not sure how much of the
code I have to "hide" and what I place in the <body> to call it up on loading. Any help would be
much appreciated. Fred
 
T

Trevor L.

When moving script to an external file you move everything between, but not
including, the <script> and </script> tags. You also delete <!-- and //-->
at the beginning and end

So in your case, the JS file will read
function load(form) {
var url = form.list.options[form.list.selectedIndex].value;
if (url != "") location.href = url; return false;}

In the HTML you place this in the <head> section
<script LANGUAGE="JavaScript" src="myscript-menu1.js">
</script>

The code in the body should not need to change
--
Cheers,
Trevor L., WIP (Web Interested Person)
Website: http://tandcl.homemail.com.au
Hi Thomas,

Sorry for using the wrong terminology. I should have said hidden from
the search engine spider when the page is crawled. Let me rephrase my
question. I assume that this is all that is placed in the <head> of
the page or can this also 'hidden' <script
LANGUAGE="JavaScript"><!--function load(form) {var url =
form.list.options[form.list.selectedIndex].value;if (url != "")
location.href = url; return false;}// --></script> Note that all
spacing has been removed.
And how much of the code in the <body> between <form NAME="menu1"> and
</select> </form>
do I save to a ( plain text file say using notepad) which I would call
myscript-menu1.js and save to my root and what text do I place in the
<body> where I want the menu to appear. Fred


Thomas A. Rowe said:
The code is not hidden when you place it in a external .js file,
actually it make it easier to "borrow" since it is in a single file
download to the user's browser's cache folder.

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
==============================================
If you feel your current issue is a results of installing
a Service Pack or security update, please contact
Microsoft Product Support Services:
http://support.microsoft.com
If the problem can be shown to have been caused by a
security update, then there is usually no charge for the call.
==============================================

BlankCould some kind person take a look at the source page of
http://www.all-inclusive-hotels.co.uk/ and show me how to hide the
long code for both the drop down menu's. I know I can save the code
to say mysripts-menu1.js but I'm not sure how much of the code I
have to "hide" and what I place in the <body> to call it up on
loading. Any help would be much appreciated. Fred
 
S

Stefan B Rusynko

And delete the invalid script starting with
<script LANGUAGE="&quot;JavaScript&quot;">
&lt;!--
and ending with
// --&gt;
</script>
--




| When moving script to an external file you move everything between, but not
| including, the <script> and </script> tags. You also delete <!-- and //-->
| at the beginning and end
|
| So in your case, the JS file will read
| function load(form) {
| var url = form.list.options[form.list.selectedIndex].value;
| if (url != "") location.href = url; return false;}
|
| In the HTML you place this in the <head> section
| <script LANGUAGE="JavaScript" src="myscript-menu1.js">
| </script>
|
| The code in the body should not need to change
| --
| Cheers,
| Trevor L., WIP (Web Interested Person)
| Website: http://tandcl.homemail.com.au
|
| Fred wrote:
| > Hi Thomas,
| >
| > Sorry for using the wrong terminology. I should have said hidden from
| > the search engine spider when the page is crawled. Let me rephrase my
| > question. I assume that this is all that is placed in the <head> of
| > the page or can this also 'hidden' <script
| > LANGUAGE="JavaScript"><!--function load(form) {var url =
| > form.list.options[form.list.selectedIndex].value;if (url != "")
| > location.href = url; return false;}// --></script> Note that all
| > spacing has been removed.
| > And how much of the code in the <body> between <form NAME="menu1"> and
| > </select> </form>
| > do I save to a ( plain text file say using notepad) which I would call
| > myscript-menu1.js and save to my root and what text do I place in the
| > <body> where I want the menu to appear. Fred
| >
| >
| > | >> The code is not hidden when you place it in a external .js file,
| >> actually it make it easier to "borrow" since it is in a single file
| >> download to the user's browser's cache folder.
| >>
| >> --
| >> ==============================================
| >> Thomas A. Rowe (Microsoft MVP - FrontPage)
| >> ==============================================
| >> If you feel your current issue is a results of installing
| >> a Service Pack or security update, please contact
| >> Microsoft Product Support Services:
| >> http://support.microsoft.com
| >> If the problem can be shown to have been caused by a
| >> security update, then there is usually no charge for the call.
| >> ==============================================
| >>
| >> | >> BlankCould some kind person take a look at the source page of
| >> http://www.all-inclusive-hotels.co.uk/ and show me how to hide the
| >> long code for both the drop down menu's. I know I can save the code
| >> to say mysripts-menu1.js but I'm not sure how much of the code I
| >> have to "hide" and what I place in the <body> to call it up on
| >> loading. Any help would be much appreciated. Fred
|
|
 
M

Murray

Search engine spiders are not troubled by javascript. They know how to hop
from <script> to </script> and ignore everything in between....

--
Murray
============

Fred said:
Hi Thomas,

Sorry for using the wrong terminology. I should have said hidden from the
search engine spider when the page is crawled. Let me rephrase my
question. I assume that this is all that is placed in the <head> of the
page or can this also 'hidden' <script LANGUAGE="JavaScript"><!--function
load(form) {var url = form.list.options[form.list.selectedIndex].value;if
(url != "") location.href = url; return false;}// --></script> Note that
all spacing has been removed.

And how much of the code in the <body> between <form NAME="menu1"> and
</select> </form>
do I save to a ( plain text file say using notepad) which I would call
myscript-menu1.js and save to my root and what text do I place in the
<body> where I want the menu to appear. Fred


Thomas A. Rowe said:
The code is not hidden when you place it in a external .js file, actually
it make it easier to "borrow" since it is in a single file download to
the user's browser's cache folder.

--
==============================================
Thomas A. Rowe (Microsoft MVP - FrontPage)
==============================================
If you feel your current issue is a results of installing
a Service Pack or security update, please contact
Microsoft Product Support Services:
http://support.microsoft.com
If the problem can be shown to have been caused by a
security update, then there is usually no charge for the call.
==============================================

BlankCould some kind person take a look at the source page of
http://www.all-inclusive-hotels.co.uk/ and show me how to hide the long
code for both the drop down menu's. I know I can save the code to say
mysripts-menu1.js but I'm not sure how much of the code I have to "hide"
and what I place in the <body> to call it up on loading. Any help would
be much appreciated. Fred
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top