Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

javascript quotes within quotes

Posted on 2015-01-19
3
Medium Priority
?
141 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 1000 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 43

Accepted Solution

by:
Rob earned 1000 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

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The task A number given should be formatted for easy reading by separating digits into triads. Format must be made inline via JavaScript, i.e., frameworks / functions are not welcome. So let’s take a number like this “12345678.91¿ and format i…
JavaScript can be used in a browser to change parts of a webpage dynamically. It begins with the following pattern: If condition W is true, do thing X to target Y after event Z. Below are some tips and tricks to help you get started with JavaScript …
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…
Suggested Courses

972 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