javascript document.write("<base href=""&g
javascript document.write("<base href="">"); not working
以下代码工作:
<base href="http://www.w3schools.com/" target="_blank">
但这不起作用:
<script>document.write('<base href="' + document.location + '" />');</script>
<script type="text/javascript">
document.write("<base href='http://" + document.location.host + "' />");
</script>
<script type="text/javascript">
document.write("<base href="http://www.w3schools.com/" target="_blank">");
</script>
http://www.customtemplates.com.au/
只需转义您的引号:
document.write("<base href='"http://www.w3schools.com/'" target='"_blank'">");
或者用简单的引号更简单:
document.write('<base href="http://www.w3schools.com/" target="_blank">');
你正在嵌套双引号。尝试切换到单引号。
<script type="text/javascript">
document.write('<base href="http://www.w3schools.com/" target="_blank">');
</script>
请不要使用 document.write。请改用 createElement。
var head = document.getElementsByTagName('head')[0]; //get the head-Element
var script = document.createElement('script'); //Create a script-element
script.setAttribute('type', 'text/javascript'); //Set an attribute
var base = document.createElement('base'); //Create a base-element
base.setAttribute('href', document.location); //Set an attribute
script.appendChild(base); //Append the base-element to the script-element
head.appendChild(script); //Append the script-element to the head-element
相关文章:
- 检测电话窃听,即:<a href="电话:xxx">在UIWebview上
- 如何提取“;href"最近列表项中的属性值
- CKEditor如何允许href="javascript:void(0)"在小部件中
- 如何使用Javascript获取当前页面URL,并在<a href="[the_URL]”>
- JSP<a href="">无法保存常规语句
- jQuery:使用.attr('href',")调用javascript
- Linkify/Clickable Text URL,但忽略那些已经包装在“;a href"'s
- 阻止href="#"链接更改URL哈希
- a href="上的javascript对象对象;javascript:"呼叫
- "href"JavaScript Android中的链接不起作用
- 菜单href="#pannel”;不适用于android
- 参考“;href"而不是html中锚点标签中的url
- 更改URL而不使用<a href="">
- 冷融合:空链接href="#"错误
- 如何检查带有href="某事“;与Jquery有一定的类
- 突出显示菜单中具有href="#"“选项”;a“;标签
- jQuery替换所有href=""其中onclick=“;window.location=“;
- <a href="#">最终调用Javascript函数
- 命令“;window.location.href"不适用于HTML(引导框架)
- href对页面的HTML调用"UP”;目录