Solved

javascript quotes within quotes

Posted on 2015-01-19
3
134 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
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…

911 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