- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我正在尝试使用 svg 绘制一条线。所以我使用了 insertAdjacentHTML
。但这适用于 chrome 但不适用于 firefox。
我的html代码如下
<div style="height:330px; width:1100px; background:#313131; margin:0 auto; ">
<svg id='svg_main' height="330" width="1100"></svg>
</div>
我的javascript如下
var svgid = document.getElementById('svg_main');
var str_lne = 60;
var data = '<path id="lineAB" d="M 50 '+str_lne+' L 1050 '+(str_lne)+'" transform="translate(0.5,0.5)" stroke="#707073" fill="none" storke-width="1px" opacity="1" ></path>';
svgid.insertAdjacentHTML('beforeend',data);
它不在 firefox(35 以下)上的本地主机上运行。
例如,
我打开 firefox 并输入 url (localhost/svgtest.html) 现在 svg 行没有显示。但是,我通过 ctrl+s 保存页面并通过 firefox 打开它显示了该行。
最佳答案
您的代码在 Firefox 中运行良好。除了您有错字 (storke-width
)。
var svgid = document.getElementById('svg_main');
var str_lne = 60;
var data = '<path id="lineAB" d="M 50 '+str_lne+' L 1050 '+(str_lne)+'" transform="translate(0.5,0.5)" stroke="#707073" fill="none" stroke-width="1px" opacity="1" ></path>';
svgid.insertAdjacentHTML('beforeend',data);
<div style="height:330px; width:1100px; background:#313131; margin:0 auto; ">
<svg id='svg_main' height="330" width="1100"></svg>
</div>
关于javascript - svg-insertAdjacentHTML 不适用于 firefox 35 及以下版本?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38305818/
我可以添加我想要的元素,但刷新后它们就会消失。使用 insertAdjacementHTML 时如何永久保存元素,还是需要使用其他方法? 示例代码: function itemAdder () {
我想在特定元素后插入 html,但 insertAdjacentHTML 不允许我先添加结束标签。 如果我这样做 elm.insertAdjacentHTML('afterend', ''); 预期结
我有两个功能。第一个是检查所有输入元素以确保它们被正确填充的那个。一切正常,但随着第二个函数开始运行(第二个函数“newInput()”添加输入),第一个函数不能再应用了。 调试器说 atpositi
fiddle - http://jsfiddle.net/u3bmytnL/ ,没有按预期工作 var x = document.createElement("button"); x.textCont
所以我使用 electron 并在我的文件“ipcRendererEvent.js”中编写了以下代码: function loadImages (images) { const imagesLis
我最近发现了 insertAdjacentHTML 方法,这是天赐之物。因此,我想知道这种方法的支持程度。 IE有吗? Chrome 呢? 最佳答案 我强烈推荐 John Resing 的这篇文章 -
我是 JavaScript 的新学习者,我正在遵循在线指南。基本上我正在创建一个非常简单的待办事项列表。我尝试按照指南进行操作,但似乎我做错了什么。它不会在网页上添加待办事项。 let ourForm
您好,我有一个简单的问题,我是否需要指定lblWelcomeUserMessage.innerHTML = ""; (见下面的代码)在下面的函数之前insertAdjacentHTML就可以了?它实际
我正在尝试从数组(JSON 编码值)动态加载一些链接作为 div 内的列表。在我的实际应用程序中,这个数组来自 PHP。 我使用 insertAdjacentHTML('beforeend', "li
我无法将样式应用于使用 .insertAdjacentHTML 创建的元素。 我试过使用 .style.cssText 但它不起作用。 JS: function addTime(){ cons
我正在尝试编写一个函数来镜像 insertAdjacentHTML dom 方法 Element.insertAdjacentHTML这是 function insertAdjacent(target
使用 native Javascript。通过 insertAdjacentHTML 添加新元素后,我想选择该元素本身( two )。如何在不搜索 DOM 的情况下获得它? // one var d1
我的 CSS 是这样的: function showNoResults() { results.innerHTML = '' results.insertAdjacentHTML( '
如何保留对新创建的元素 (createElement()) 的引用,该元素是我在 DOM 中的现有元素 (insertAdjacentHTML()) 之后插入的? 在此示例中,如果我在 insertA
出于某种原因,在 FF 中使用 insertAdjacentHtml 函数时出现 insertAdjacentHTMl is not a function 错误,在 jQuery 或其他一些替代 ja
我有一个很长的文本包含在一个 中标签。像这样: Lorem ipsum dolor sit amet consectetur adipiscing elit sed do eiusmod...
我可以使用 insertAdjacentHTML执行内联 JavaScript? 浏览器控制台的工作原理: $('body').append('alert(1)') 我需要在浏览器控制台中工作: do
尝试执行此代码时,IE 给我一个错误(错误:此操作的目标元素无效。): var d1 = document.getElementById( name + '-body'); d1.insertAdja
我正在尝试在单击某个按钮时添加新的输入和按钮。 ... Add 这是我的问题。 通过单击按
是否可以在 Jquery 中为 insertAdjacentHTML 设置动画?现在它只是将其直接粘贴到指定的 div 中。 当前函数 $(".select-category").click(func
我是一名优秀的程序员,十分优秀!