Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/380.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/90.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
带有多个单引号和双引号的java html内容 你好,这是一个很简单的问题,但我无法回答 我已经为html内容字符串编写了java代码 我的目标是:点击这里打开yahoo.com和google.com页面 我可以打开html并单击单击此处标记我只打开yahoo.com页面和无法打开google.com页面 我面临着在正确位置使用符号的问题_Java_Html_String_Quotations_Quotation Marks - Fatal编程技术网

带有多个单引号和双引号的java html内容 你好,这是一个很简单的问题,但我无法回答 我已经为html内容字符串编写了java代码 我的目标是:点击这里打开yahoo.com和google.com页面 我可以打开html并单击单击此处标记我只打开yahoo.com页面和无法打开google.com页面 我面临着在正确位置使用符号的问题

带有多个单引号和双引号的java html内容 你好,这是一个很简单的问题,但我无法回答 我已经为html内容字符串编写了java代码 我的目标是:点击这里打开yahoo.com和google.com页面 我可以打开html并单击单击此处标记我只打开yahoo.com页面和无法打开google.com页面 我面临着在正确位置使用符号的问题,java,html,string,quotations,quotation-marks,Java,Html,String,Quotations,Quotation Marks,代码是 String content; content = "<html><head>....." +"<a href='http://yahoo.com' " + "onclick=\"window.open('http://google.com'); \">" + "Click Here</a>" .... +"</body>" +"</html>" 字符串内容; content=“…” +"" .... +"" +"

代码是

String content;
content = "<html><head>....."
+"<a href='http://yahoo.com' "
+ "onclick=\"window.open('http://google.com'); \">"
+ "Click Here</a>"
....
+"</body>"
+"</html>"
字符串内容;
content=“…”
+""
....
+""
+""
我试过这个:

public class Test{

 public static void main(String []args){
    System.out.println("Hello World");
    String content;
    content = "<html><head>"
    +"<a href='http://yahoo.com'"
    + "onclick=\"window.open('http://google.com'); \">"
    + "Click Here</a>"
    +"</body>"
    +"</html>";
    System.out.println(content);
 }
公共类测试{
公共静态void main(字符串[]args){
System.out.println(“你好世界”);
字符串内容;
content=“”
+""
+""
+"";
系统输出打印项次(内容);
}
}

并将生成的字符串粘贴到一个空白html文件中,在浏览器中打开它,看到它如我所期望的那样工作(一个指向Yahoo的链接,同时打开Yahoo和Google)。

我尝试了以下方法:

public class Test{

 public static void main(String []args){
    System.out.println("Hello World");
    String content;
    content = "<html><head>"
    +"<a href='http://yahoo.com'"
    + "onclick=\"window.open('http://google.com'); \">"
    + "Click Here</a>"
    +"</body>"
    +"</html>";
    System.out.println(content);
 }
公共类测试{
公共静态void main(字符串[]args){
System.out.println(“你好世界”);
字符串内容;
content=“”
+""
+""
+"";
系统输出打印项次(内容);
}
}


并将结果字符串粘贴到一个空白html文件中,在浏览器中打开它,看到它如我所期望的那样工作(一个指向Yahoo的链接,同时打开Yahoo和Google。)。

实际代码中是否缺少分号?您遇到了什么样的错误?@cartesiantheter,感谢您的重播,此字符串内容添加到
电子邮件中。setHtml(content)
,在电子邮件中单击单击此处我无法打开google.com,我可以打开yahoo.com。您提到这将进入电子邮件。电子邮件客户端对HTML内容的限制更严格,有助于保护用户免受恶意代码的攻击。也许电子邮件客户端选择忽略onclick或window.open javascript调用。@DanArmstrong,谢谢你,Dan,请你建议如何调用两个href以获取电子邮件html内容中的单个文本。这有点像跳出框框。但是,您可以链接到服务器上的一个页面,该页面通过一个小脚本完成繁重的工作。邮件客户端在浏览器中打开指向此脚本的单个URL,然后浏览器在脚本中执行“window.open”和“window.location.href”。更复杂的是,我遗漏了很多细节,但只是介绍了一个服务器组件的概念来弥补这一差距。实际代码中是否缺少分号?您遇到了什么样的错误?@cartesiantheter,感谢您的重播,此字符串内容添加到
电子邮件中。setHtml(content)
,在电子邮件中单击单击此处我无法打开google.com,我可以打开yahoo.com。您提到这将进入电子邮件。电子邮件客户端对HTML内容的限制更严格,有助于保护用户免受恶意代码的攻击。也许电子邮件客户端选择忽略onclick或window.open javascript调用。@DanArmstrong,谢谢你,Dan,请你建议如何调用两个href以获取电子邮件html内容中的单个文本。这有点像跳出框框。但是,您可以链接到服务器上的一个页面,该页面通过一个小脚本完成繁重的工作。邮件客户端在浏览器中打开指向此脚本的单个URL,然后浏览器在脚本中执行“window.open”和“window.location.href”。更复杂的是,我遗漏了很多细节,但只是介绍了一个服务器组件的想法来弥补差距。感谢您的重播,这个字符串内容添加到
email.setHtml(content)
,我收到了带有这个html正文的电子邮件,但是在电子邮件中单击ClickHere,我无法打开google.com,我可以打开yahoo.com..感谢您的重播,这个字符串内容添加到
email.setHtml(content)
,我收到了带有这个html正文的电子邮件,但是在电子邮件中单击ClickHere,我无法打开google.com,我可以打开yahoo.com。。