jjzjj

setattribute

全部标签

javascript - 在运行时向我的文档添加更多 svg 元素

我有一个html文件,我正在向它动态添加一个元素,然后是一个矩形。在不同的浏览器中运行良好(忽略IE)。当我尝试使用相同的方法动态创建元素时,它在Chrome或Safari中不起作用,只能在Opera中起作用。是我的语法错误,还是webkit可能只是不支持在运行时添加元素?(如果我预先将其声明为标签,则相同的元素可以正常工作)。也许我不应该对这些类型的节点使用appendChild()?这就是我所拥有的,您应该能够将它转储到一个html文件中并运行它。如果有人知道是否有办法解决这个问题,那就太好了:window.onload=function(){varsvg=document.cre

Javascript 和文件上传无法按预期使用 click()

我正在用javascript创建一个上传控件,然后使用element.click()打开文件浏览器对话框。functionadd(type){varelement=document.createElement("input");element.setAttribute("type",type);element.setAttribute("value",type);element.setAttribute("name",type);element.setAttribute("id","element-"+i);varremovebutton=document.createElement(

javascript - 如何在 Firefox 插件中从 main.js 调用内容脚本函数

我是Firefox插件开发的新手。我需要一种在Firefox插件中从main.js调用contentscript函数的方法。我在每个打开的网页上都注入(inject)了contentscriptxyz.js。我想通过单击我放置在导航工具栏中的按钮从我的main.js调用我的contentscriptxyz.js中存在的函数abc()。下面是我的代码。主要.js..functionaddToolbarButton(){vardocument=mediator.getMostRecentWindow('navigator:browser').document;varnavBar=docum

javascript - 如何使用 Javascript 动态更改 SVG 中的图像模式

如何使用Javascript将图像模式动态更改/添加到我页面上的现有SVG中?或任何图书馆。这就是我到目前为止所得到的..functionaddSvgStuff(svg,id){varsvgNS=svg.namespaceURI;varpattern=document.createElementNS(svgNS,'pattern');pattern.setAttribute('id',id);pattern.setAttribute('patternUnits','userSpaceOnUse');pattern.setAttribute('width',500);pattern.se

javascript - 使用 svg 设置属性的更简单方法?

我是SVG的新手,所以我为我的无知提前道歉。我创建了一个fiddle,只是把玩一些东西。http://jsfiddle.net/a46p8/varsvg=document.createElementNS('http://www.w3.org/2000/svg','svg');svg.setAttribute('width','200');svg.setAttribute('height','200');varline=document.createElementNS('http://www.w3.org/2000/svg','line');line.setAttribute('widt

javascript - 使用 Javascript onclick 更改图像 alt

我有一个缩略图,单击它会在页面上更改为更大的图像。我通过使用onclick更改.src来让那部分代码工作。还有一种方法可以通过onclick更改alt和title属性吗? 最佳答案 您可以使用setAttribute或直接设置属性。无论哪种方式都有效,setAttribute是标准的DOM方法。el.onclick=function(){vart=document.getElementById('blah');//firstwayt.src='blah.jpg';t.title='newtitle';t.alt='foo';//al

javascript - document.getElementById(...).setAttribute ('style' ,... 在 Internet Explorer 中不起作用

这个问题在这里已经有了答案:setAttributeisnotworkingfor'style'attributeonIE(6个答案)关闭8年前。document.getElementById(...).setAttribute('style',...在InternetExplorer7.0中不工作。我怎样才能在InternetExplorer中工作?varmyarray=newArray(3);for(i=0;iold

javascript - 用于在查找时禁用 View 选择器的 Jscript 在 CRM 2013 中不起作用

我正在使用MSDynamicsCRM2013,我正面临下一个问题:在CRM2011中,我使用下一个jscript禁用了查找时的View和实体选择:document.getElementById("lookup_id").setAttribute("disableViewPicker","1");document.getElementById("lookup_id").setAttribute("defaulttype","1");document.getElementById("lookup_id").setAttribute("lookuptypenames","account:1:

javascript - firefox 扩展通过 sdk 工作,但在浏览器中安装时不工作 - 兼容性问题?

---更新----在对此进行更多试验后,我确定我编写的contentScript不是这里的问题。例如,如果我将扩展名缩减为:varbuttons=require('sdk/ui/button/action');vardata=require("sdk/self").data;varself=require("sdk/self");varbutton=buttons.ActionButton({id:"library-link",label:"ExternalResourceLocator",icon:self.data.url("icon-16.png"),});当我通过SDK运行扩展

javascript - 如何在 JavaScript 中向 SVG 对象添加过滤器?

我正在尝试使用JavaScript创建feGaussianBlur滤镜并将其添加到SVG矩形,使用thiscode作为引用。我得到一个矩形,但它没有被过滤。我做错了什么?我正在尝试这样:varcontainer=document.getElementById("svgContainer");varmySvg=document.createElementNS("http://www.w3.org/2000/svg","svg");mySvg.setAttribute("version","1.1");container.appendChild(mySvg);varobj=document