Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 26th, 2006, 12:24 AM   #1
dpsleep
Newbie
 
Join Date: May 2006
Posts: 16
Rep Power: 0 dpsleep is on a distinguished road
entering image data into js

im working with prototype.js and thickbox trying to insert the image data from http://software.hixie.ch/utilities/cgi/data/data into the js.i wanted to change
$("body").append("<div id='TB_load'><div id='TB_loadContent'><img src='pictures/circle_animation.gif' /></div></div>");
to
$("body").append('<div id='TB_load'><div id='TB_loadContent'><img src="image data" /></div></div>');

the only problem is the image data has a bunch of single quote marks in it.
anyone has an idea on what i should do here?
dpsleep is offline   Reply With Quote
Old May 26th, 2006, 12:41 AM   #2
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,799
Rep Power: 5 Sane will become famous soon enough
Every time you want to use a single-quote, use a \ before it. In javascript \ is the escape character, it allows you to escape the functionality of the single quote.

\'

Example:

document.write('<a href="javascript: popup(\'http://google.com\');">Google</a>');
Sane is offline   Reply With Quote
Old May 26th, 2006, 12:45 AM   #3
dpsleep
Newbie
 
Join Date: May 2006
Posts: 16
Rep Power: 0 dpsleep is on a distinguished road
well ill go ahead and try that, might take a while though...
edit: well that didnt work, i used word's replace feature to do that a little faster but in the end the js is still broken
dpsleep is offline   Reply With Quote
Old May 26th, 2006, 12:49 AM   #4
Sane
Programming Guru
 
Sane's Avatar
 
Join Date: Apr 2005
Posts: 1,799
Rep Power: 5 Sane will become famous soon enough
I'm sorry, I was wrong. I updated my post with the correct answer.
Sane is offline   Reply With Quote
Old May 26th, 2006, 12:51 AM   #5
dpsleep
Newbie
 
Join Date: May 2006
Posts: 16
Rep Power: 0 dpsleep is on a distinguished road
ahh, ok. should have tryed that before, ill do it now
edit: well it still doesnt seem to be working, of you goto www.cycodude.com/gallary and view the source then do a search for this string
$("body").append('<div id='TB_load'>
thats where im trying to put it.

Last edited by dpsleep; May 26th, 2006 at 1:14 AM.
dpsleep is offline   Reply With Quote
Old May 26th, 2006, 1:47 AM   #6
dpsleep
Newbie
 
Join Date: May 2006
Posts: 16
Rep Power: 0 dpsleep is on a distinguished road
ok so i used \. and it works for the most part, only problem is now it breaks the image, shows up all distorted
dpsleep is offline   Reply With Quote
Old May 26th, 2006, 3:18 AM   #7
dpsleep
Newbie
 
Join Date: May 2006
Posts: 16
Rep Power: 0 dpsleep is on a distinguished road
ok well i fixed it by just entering <loding></loading> where the image was loading and puting the image code in the css. works great so no worries now. but thanks for trying. great forums you got here.
dpsleep is offline   Reply With Quote
Old May 26th, 2006, 9:14 AM   #8
Cerulean
Professional Programmer
 
Cerulean's Avatar
 
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4 Cerulean is on a distinguished road
What on earth is a loading tag? Did you just make that up? I think you just need to put something inside the div element - a non-breaking space (&nbsp would do.
Cerulean is offline   Reply With Quote
Old May 26th, 2006, 9:25 AM   #9
DaWei
Resident Grouch
 
DaWei's Avatar
 
Join Date: Jun 2005
Posts: 6,453
Rep Power: 10 DaWei is on a distinguished road
Even if you use the dreaded "loading" tag, I'd suggest you not mix it with the "loding" version .
__________________
Abstraction doesn't make it impossible to write bad code; it makes it possible to write superior code.
Contributor's Corner: Grumpy on C++ Exceptions DaWei on Pointers
DaWei is offline   Reply With Quote
Old May 26th, 2006, 10:03 AM   #10
Ooble
I eat cake for breakfast.
 
Ooble's Avatar
 
Join Date: Jul 2004
Location: In my box.
Posts: 4,434
Rep Power: 9 Ooble is on a distinguished road
Quote:
Originally Posted by dpsleep
im working with prototype.js and thickbox trying to insert the image data from http://software.hixie.ch/utilities/cgi/data/data into the js.i wanted to change
$("body").append("<div id='TB_load'><div id='TB_loadContent'><img src='pictures/circle_animation.gif' /></div></div>");
to
$("body").append('<div id='TB_load'><div id='TB_loadContent'><img src="image data" /></div></div>');

the only problem is the image data has a bunch of single quote marks in it.
anyone has an idea on what i should do here?
That's nowhere near the only problem. I have no idea what $("body") means, but I can guess you're trying to do something like this:
image = document.createElement("img");
image.src = "my_image.png";
image.alt = "Picture!!!11";

holder = document.createElement("div");
holder.id = "TB_load";
holder.appendChild(image);

body = document.getElementsByTagName("body")[0];
body.appendChild(holder);

Disclaimer: not tested - there's likely to be a bug or two.
__________________
Me :: You :: Them
Ooble is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:11 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC