Solved

javascript quotes within quotes

Posted on 2015-01-19
3
133 Views
Last Modified: 2015-01-20
This is probably a rather simple question, but web searching has turned up the wrong answers. I have the following line in an html file:

onmouseover="document.body.style.cursor='pointer'; this.style.backgroundImage=\"url ('images/E-hover.png')\";"

It doesn't work with quotes escaped as shown. How do I make this work?
0
Comment
Question by:jmarkfoley
3 Comments
 
LVL 38

Assisted Solution

by:Tom Beck
Tom Beck earned 250 total points
ID: 40559004
Try this. The background image url should work without quotes.

onmouseover="document.body.style.cursor='pointer'; this.style.backgroundImage='url (images/E-hover.png)';"
0
 
LVL 42

Accepted Solution

by:
Rob Jurd, EE MVE earned 250 total points
ID: 40559087
Or keep your quoting style the same (single inside, double outside): http://jsbin.com/difaye/1/edit?html,output

onmouseover="document.body.style.cursor='pointer'; this.style.backgroundImage='url(\'images/E-hover.png\')'"
0
 
LVL 1

Author Comment

by:jmarkfoley
ID: 40561295
Both of those ideas worked! Good to know both. Rob Jurd's will work if I have a URL with embedded spaces.
0

Featured Post

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now