473,765 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Writing a backslash into the style tag

Hi, I'm trying to write a backslash as a text node into the style tag
of a web page, but IE is not letting me(perhaps because of security or
something?). I need to write a backslash because it is part of the
style rule needed to draw VML images. This is my current code at the
moment:
var theTextofStyle = document.create TextNode('v\:* { behavior:
url(#default#VM L); }');
document.getEle mentsByTagName( 'style')[0].appendChild(th eTextofStyle);

I've tried all the usual ways to escape the backslash, but IE still
won't let me write it into the style element.

Anyone have any ideas on getting around this?

Cheers.

Mar 27 '07 #1
5 1795
On Mar 27, 3:30 pm, "Yansky" <forbo...@gmail .comwrote:
Hi, I'm trying to write a backslash as a text node into the style tag
of a web page, but IE is not letting me(perhaps because of security or
something?). I need to write a backslash because it is part of the
style rule needed to draw VML images. This is my current code at the
moment:

var theTextofStyle = document.create TextNode('v\:* { behavior:
url(#default#VM L); }');
document.getEle mentsByTagName( 'style')[0].appendChild(th eTextofStyle);

I've tried all the usual ways to escape the backslash, but IE still
won't let me write it into the style element.

Anyone have any ideas on getting around this?
What happens when you do the conventional c-slash escaping:

var theTextofStyle = document.create TextNode('v\\:* { behavior:
url(#default#VM L); }');)?

Mar 27 '07 #2
VK
On Mar 27, 11:30 pm, "Yansky" <forbo...@gmail .comwrote:
This is my current code at the
moment:

var theTextofStyle = document.create TextNode('v\:* { behavior:
url(#default#VM L); }');
document.getEle mentsByTagName( 'style')[0].appendChild(th eTextofStyle);

I've tried all the usual ways to escape the backslash, but IE still
won't let me write it into the style element.

Anyone have any ideas on getting around this?
Yes, I do. But just a year ago I would stay silent as it was the
biggest capitalization for myself out of simply reading producer
specs :-) :-| Now the retaining period is over. I am not saying that
I'm the only one who can read MSDN, but in this particular case it
seemed so for all the time of my interest.

First get rid of all this stuff you posted.

Now:

// missing namespaces return null
if (document.names paces.item('v') == null) {
// then adding the required namespace/behavior combo:
document.namesp aces.add('v', 'urn:schemas-microsoft-com:vml',
'#default#VML') ;
}
// now you can draw whatever you want using VML

The page itself stays "clean" in the sense that you don't add any IE-
specific attributes into <htmlor <style>

Mar 27 '07 #3
On Mar 28, 6:07 am, "Weston" <notsew-
reversePreceedi ngAndRemoveT... @canncentral.or gwrote:
On Mar 27, 3:30 pm, "Yansky" <forbo...@gmail .comwrote:
Hi, I'm trying to write a backslash as a text node into the style tag
of a web page, but IE is not letting me(perhaps because of security or
something?). I need to write a backslash because it is part of the
style rule needed to draw VML images. This is my current code at the
moment:
var theTextofStyle = document.create TextNode('v\:* { behavior:
url(#default#VM L); }');
document.getEle mentsByTagName( 'style')[0].appendChild(th eTextofStyle);
I've tried all the usual ways to escape the backslash, but IE still
won't let me write it into the style element.
Anyone have any ideas on getting around this?

What happens when you do the conventional c-slash escaping:

var theTextofStyle = document.create TextNode('v\\:* { behavior:
url(#default#VM L); }');)?
It still doesn't work. It gives me an error of "Object doesn't support
this property or method"

Mar 27 '07 #4
On Mar 28, 6:17 am, "VK" <schools_r...@y ahoo.comwrote:
On Mar 27, 11:30 pm, "Yansky" <forbo...@gmail .comwrote:
This is my current code at the
moment:
var theTextofStyle = document.create TextNode('v\:* { behavior:
url(#default#VM L); }');
document.getEle mentsByTagName( 'style')[0].appendChild(th eTextofStyle);
I've tried all the usual ways to escape the backslash, but IE still
won't let me write it into the style element.
Anyone have any ideas on getting around this?

Yes, I do. But just a year ago I would stay silent as it was the
biggest capitalization for myself out of simply reading producer
specs :-) :-| Now the retaining period is over. I am not saying that
I'm the only one who can read MSDN, but in this particular case it
seemed so for all the time of my interest.

First get rid of all this stuff you posted.

Now:

// missing namespaces return null
if (document.names paces.item('v') == null) {
// then adding the required namespace/behavior combo:
document.namesp aces.add('v', 'urn:schemas-microsoft-com:vml',
'#default#VML') ;}

// now you can draw whatever you want using VML

The page itself stays "clean" in the sense that you don't add any IE-
specific attributes into <htmlor <style>
I've already got <html xmlns:v="urn:sc hemas-microsoft-com:vml" as my
namespace, but the VML still doesn't seem to render unless I put v\:*
{ behavior:url(#d efault#VML); } in the style tag. :(

Mar 27 '07 #5
I think I found a solution. There's an "IE specific"
createStyleShee t() function that was added in version 6. It's working
a treat. :)

http://msdn.microsoft.com/workshop/a...stylesheet.asp

Thanks for your replies anyway guys. :)

Mar 27 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
22234
by: Terry Asher | last post by:
The following script does NOT escape the Apostrophe. Meaning when you mouseover the image the Alt tag says this: DMACC, It and then it stops. <SCRIPT Language="JavaScript"> var pos = "DMACC, It\'s the Smart Thing to Do."; document.write("<img name=img5 id=img5 src='/homepage/dmaccstudent" + Math.floor(Math.random() *20) + ".jpg' WIDTH=145 HEIGHT=230 border=0 ALT='"+pos+"'>"); </SCRIPT>
3
5755
by: Sathyaish | last post by:
In trying to replace character literals for their char constant, I am having difficulty printing the char constant for backslash. It instead prints the char literal. How do I resovle this? #include <stdio.h> /*A program that reads keyboard input and reproduces it on the monitor with some modifications. It displays all newline character occurences as \n, tabs as \t and
19
6347
by: Alan J. Flavell | last post by:
The story so far: on somewhat unrelated newsgroup, my attention fell upon the URL: http://www.speedtouchdsl.com/prod706.htm which contains a link to the purported URL: http://www.speedtouchdsl.com/pdf\datasheet706WL-780WL.pdf Comparing the latter with other URLs in that area, it appeared that the "\" was a probable blunder for "/". However, since their web server is IIS, it appears that their server silently fixes-up this blunder, and...
2
3245
by: John Dann | last post by:
I guess there must be some convention or Windows specification for whether the backslash immediately preceding the file name in a full path string to a file is formally part of the path string or of the file name. I suppose the options are: 1. Part of the path string, ie all returned path strings should have a trailing backslash. 2. Part of the file name, ie all file names should start with a backslash.
3
23010
by: Stef Mientki | last post by:
It looks like sometimes a single backslash is replaced by a double backslash, but sometimes it's not ??? See the error message below, the first backslash is somewhere (not explicitly in my code) replaced, but the second is not ??? Is it in general better to use double backslash in filepaths ? thanks, Stef Mientki
2
2179
by: Tobiah | last post by:
>>"'" "'" "'" "\\'" "\\'" This is quite different than any other language that I am used to. Normally, a double backslash takes away the special meaning of the last backslash, and so you are left with a single backslash.
5
15689
by: vlsidesign | last post by:
The printf function returns "warning: unknown escape sequence: \040" for a backslash-space combination. If the ascii decimal number for space is 32 and the backslash is 92, why this particular number 040? Is it a decimal number from the ASCII code chart? (compiling using gcc on SunOS 5.8, Sparc, Ultra-80) Just curious. Thanks.
4
2276
by: Razzbar | last post by:
I'm working on a bookmarklet that grabs information from a page and submits it to a server. Yet another social bookmarking application. I'm having trouble with page titles that include an apostrophe. I'm using encodeURIComponent() around the page title, and again around the URL. Apparently the browser is inserting a backslash before any apostrophe. I can see that when I write the $_GET data to a file in PHP on the server. When the GET...
4
3623
nithinpes
by: nithinpes | last post by:
I will boil down my exact requirement to this: I should print out lines that do not contain semi-colon, backslash and closing parentheses. The following one -liner works fine. perl -ne "unless(//) {print}" in.txt > out.txt Consider the following sample data: Msg_create(….); \ PSLogI18N\ Free( ….)
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9399
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10163
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9835
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5423
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3532
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.