• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Bear Bibeault
  • Devaka Cooray
  • Liutauras Vilda
  • Jeanne Boyarsky
Sheriffs:
  • Knute Snortum
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Ganesh Patekar
  • Frits Walraven
  • Tim Moores
  • Ron McLeod
  • Carey Brown
Bartenders:
  • Stephan van Hulst
  • salvin francis
  • Tim Holloway

How do I link to JavaScript?  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All

Novice, so excuse me if im not making sense! I had loads of script on my page, so I though it was best to save it in a js file and put a link into my html page.

It doesnt work....

Does this look wrong?

Thank you! Kitty

<script src="swapimage.js" type="text/javascript"></script>
<SCRIPT SRC="../bridesmaid.dresses/bridesmaid.dresses.js">

</SCRIPT>
 
author
Posts: 23811
140
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Java and Javascript are two completely different languages. Are you trying to run a java program as a javascript? Or are you asking a HTML / Javascript question?

For the first, you can't do that. For the second, I can move this topic to the JS forum for you.

Henry
 
Marshal
Posts: 61766
193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

Please supply more details of what is going wrong, otherwise we an't help. Henry is right; this thread belongs in the JS forum.
 
Katie Sykes
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Apologies, I believe its script. Its basically a load of code which allows an image to replace another image when the mouse rolls over it. Its a lot of code. I was concerned that google would scan it, and the page is so messy, that O thought I could just save it to a file and link it,

Thank you
 
Campbell Ritchie
Marshal
Posts: 61766
193
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
People usually prefer to see the code directly rather than having to open files; some people are even suspicious about opening files. Also, please provide details about what is going wrong.
 
Bartender
Posts: 19993
95
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Google has seen a lot of messy pages. As, alas, have I.

If you're looking for a setup where you have 2 images and one shows when the mouse is over the image area but a different one shows when the mouse is not, that's a common javascript trick and no Java is required. Nor, for that matter, any post-page load contact with a server.

If you have something more like a dynamic gallery where the images can change, then you'd probably use AJAX, which employs javascript to upload an image from the server dynamically when you roll the mouse over the "hot" area.
 
Marshal
Posts: 67164
169
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Katie Sykes wrote:I was concerned that google would scan it, and the page is so messy, that O thought I could just save it to a file and link it,


Saving it to a file and linking it will make no difference to how Google indexes your pages and code. So if your intent is to "hide" the code from Google, it isn't happening.

Rather, I'd suggest using this opportunity make the code less messy rather than a doomed attempt to hide it. What you are describing should only take a handful of code. If there's a "lot of it", it likely could use improving.
 
Bear Bibeault
Marshal
Posts: 67164
169
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
By the way, that is not to say that moving the JavaScript to separate file(s) is a bad idea. In fact, it has many advantages both at development and run times. It just won't achieve any sort of hiding.

Your issue is likely that the file is not addressed correctly. Where is it in the file system relative to the HTML file?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!