?
Solved

javascript quotes within quotes

Posted on 2015-01-19
3
Medium Priority
?
139 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

In Part 1 (http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_7849-Hex-Maze.html) we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
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…
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

752 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