This week's book giveaway is in the NodeJS forum.
We're giving away four copies of Serverless Applications with Node.js and have Slobodan Stojanovic & Aleksandar Simovic on-line!
See this thread for details.
Win a copy of Serverless Applications with Node.js this week in the NodeJS forum!
  • 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
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • Vijitha Kumara

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: 23821
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: 63804
209
  • 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: 63804
209
  • 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: 20568
120
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: 67255
170
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: 67255
170
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?
 
Put the moon back where you found it! We need it for tides and poetry and stuff. Like this tiny ad:
global solutions you can do at home or in your backyard
https://www.kickstarter.com/projects/paulwheaton/better-world-boo
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!