我的脚本有问题。如果文件名有单引号,则文件不会打开。
有没有办法防止window.open中的单引号?
<a class="btn btn-primary btn-xs" onclick="window.open('content_files/<?php print($contRow['cont_file']); ?>','<?php print($contRow['cont_file']); ?>','height:auto;width:auto;')">
<i class="glyphicon glyphicon-edit"></i> View
</a>
这是输出
D'Sound @ Ultimate-Guitar <7> TATTOOED ON MY MIND CHORDS(ver 2)答案 0 :(得分:2)
您应该对我的文件名进行编码:
StringWriter sw = new StringWriter();
OutputStream out = null ; which object wrap sw here?
try (ObjectOutputStream obj = new ObjectOutputStream(out)){
} catch (IOException e) {
e.printStackTrace();
}
答案 1 :(得分:0)
我试过这段代码:
<a class="btn btn-primary btn-xs" onclick="window.open('content_files/<?php print(addslashes($contRow['cont_file'])); ?>','<?php print(addslashes($contRow['cont_file'])); ?>','height:auto;width:auto;')">
<i class="glyphicon glyphicon-edit"></i> View
</a>