i need to use the " symbol in java
I'm having some hard trouble finding the answer for this
Is there anyway to use the " symbol in java without it assumes that is a text... The ideal i think would be to save the " to a string.
Can it be done?
I need it because of this, the call of the script is working in dreamweaver
onChange="album(this.value,'albumAlvo')"
but I'm using a javascript call in a dynamic webpage generated by java, and for printing the page am ch开发者_高级运维anging the " to ' ending with this as example:
"<table width='100%' border='0' cellspacing='3' cellpadding='0' class='t1'>"+
"<tr><td>"+
that changes my call to
onChange='album(this.value,'albumAlvo')'>
And this way doesnt work. Apparently i really need the " to make this work. anyone can help me please?
Edited: Just a clearing, this question is about java and coding in a java environment in a java *.class, in a project for google app engine that uses java that prints html web-pages. The only reason why javascript is here is that in fact I needed to call a method from the webpage that was printed by the java web application, but that was irrelevant cause my doubt was for the use of the " symbol. I thank all for the quick answer.
Just escape it with backslash in your Java program when you create the strings.
"<table width=\"100%\" border=\"0\" cellspacing=\"3\" cellpadding=\"0\" class=\"t1\">"+
"<tr><td>"
In Java, you can include a double quote in a String by escaping the "
character like this: \"
.
So you're string would look like this:
"<table width=\"100%\" border=\"0\" cellspacing=\"3\" cellpadding=\"0\" class=\"t1\">"+
"<tr><td>"
I'm no Javascript expert (this question was tagged as Java when it appears it should be tagged as Javascript), but can you not escape double quotes in Javascript as \" ?
try using \" inside your quotations.
If \'
is not working then you can try with \\'
精彩评论