标签: setattribute

Internet Explorer"setAttribute"onclick解决方法?

var tr = document.createElement('tr');
tr.setAttribute("onclick",p.onrowclick+"("+row.id+")");
Run Code Online (Sandbox Code Playgroud)

嗨,以上在Firefox中对我来说很好.我在IE中找不到正确的解决方法语法.

我正在使用IE8.

javascript internet-explorer onclick setattribute

5
推荐指数
1
解决办法
2835
查看次数

Grails - 在GSP中设置"已禁用"属性名称和值

我试图这样做没有成功:

<g:textField title="${title}" ${disabled} />
Run Code Online (Sandbox Code Playgroud)

我想要应用一个禁用的属性,仅在$ {disabled}变量为TRUE时.我不想使用条件,因为在其他视图中我获得了大量代码并使用IF语句,将是一个混乱.

另一件事是应用这样的属性:

<g:textField title="${title}" disabled="${disabled}" />
Run Code Online (Sandbox Code Playgroud)

但是当我把disabled属性放在一起时,没有变量的内容,它总是禁用该字段.

html grails taglib setattribute gsp

5
推荐指数
2
解决办法
9786
查看次数

新的Audio()未在Internet Explorer中实现

我正在尝试播放一系列mp3声音.我的html中有一个音频文件,并document.CreateElement()在我的JavaScript中使用它.

当我尝试设置src属性(setAttribute("src", string))时,我在IE中收到错误,说"未实现".

我尝试使用新的Audio(),我在IE中得到了同样的错误,"Not Implemented".这两种方法都适用于Google Chrome和Firefox.

有人可以帮忙吗?

<audio id="audio1" >Not supported</audio>
Run Code Online (Sandbox Code Playgroud)
audioElm = document.getElementById("audio1");
audioElm.setAttribute("src", aud[count]); 
audioElm.play();
Run Code Online (Sandbox Code Playgroud)

javascript audio html5 internet-explorer setattribute

5
推荐指数
1
解决办法
1800
查看次数

Python setattr()函数采用初始函数名称

我确实了解setattr()python的工作原理,但是我的问题是当我尝试动态设置属性并将其未绑定函数作为值提供时,因此该属性是可调用的,当我使用该属性时,该属性最终会使用未绑定函数的名称调用attr.__name__,而不是属性的名称。

这是一个例子:

我有一Filter堂课:

class Filter:
    def __init__(self, column=['poi_id', 'tp.event'], access=['con', 'don']):
        self.column = column
        self.access = access
        self.accessor_column = dict(zip(self.access, self.column))
        self.set_conditions()

    def condition(self, name):
        # i want to be able to get the name of the dynamically set 
        # function and check `self.accessor_column` for a value, but when
        # i do `setattr(self, 'accessor', self.condition)`, the function 
        # name is always set to `condition` rather than `accessor`
        return name

    def set_conditions(self):
        mapping = list(zip(self.column, …
Run Code Online (Sandbox Code Playgroud)

python class setattribute setattr dynamic-function

5
推荐指数
1
解决办法
89
查看次数

HTML更改为element.setAttribute("onclick","alert('Test');")和element.onclick ="alert('Test');";

比较下列情况时,我感到很惊讶:

button = document.getElementById("addSugerenciaButton");

if (button != null) {
   button.onclick = "post_to_url('" + addSugerenciaURL + "', idBuzon', '" + id + "');";
}

button = document.getElementById("removeBuzonButton");

if (button != null) {
    button.onclick = function() {
        if (!confirm(removeSugerenciaMessage)) {
            return false; 
        };
        post_to_url(removeBuzonURL, 'idBuzon', id);
    };
}

button = document.getElementById("editBuzonButton");

if (button != null) {
    button.setAttribute("onclick","post_to_url('" + editBuzonURL + "', 'idBuzon', '" + id + "');");
}
Run Code Online (Sandbox Code Playgroud)

只是后者似乎改变了HTML(至少用Firebug进行检查),其余的虽然也正常工作,但他们没有在editBuzonButton元素中显示任何onclick事件.

任何想法为什么会这样?

javascript onclick setattribute

4
推荐指数
1
解决办法
2万
查看次数

Webbrowser SetAttribute 不工作(密码字段)

试图编写一个程序,它可以让我在 C# 中的网络浏览器中自动登录。这是我目前为此目的使用的代码:

HtmlElementCollection pageTextElements = loginBrowser.Document.GetElementsByTagName("input");
        foreach (HtmlElement element in pageTextElements)
        {
            if (element.Name.Equals("username"))
                element.SetAttribute("value", this.UserName);
            if (element.Name.Equals("password"))
                element.SetAttribute("value", this.Password);
        }
Run Code Online (Sandbox Code Playgroud)

它填写用户名,而不填写密码?): 谷歌搜索,但只有少数人开始了没有人回复的话题。/:

希望有人可以帮助我。这是密码字段的源 auf:

<input type="password" value="" maxlength="50" size="25" name="password" class="bginput">
Run Code Online (Sandbox Code Playgroud)

c# browser passwords setattribute

4
推荐指数
1
解决办法
9440
查看次数

在元素上设置命名空间属性

我正在尝试用Java创建一个包含以下元素的XML文档:

<project xmlns="http://www.imsglobal.org/xsd/ims_qtiasiv1p2" 
         xmlns:acme="http://www.acme.com/schemas"
         color="blue">
Run Code Online (Sandbox Code Playgroud)

我知道如何创建项目Node.我也知道如何使用颜色属性

element.setAttribute("color", "blue")

我是否使用setAttribute()以相同的方式设置xmlns和xmlns:acme属性,或者我是否以某种特殊方式执行它,因为它们是命名空间属性?

java xml setattribute xml-namespaces

4
推荐指数
1
解决办法
2万
查看次数

TypeError:node.setAttribute不是函数

我收到一个错误:当我尝试在我的网页上调用以下函数时,"TypeError:item.setAttribute不是函数":

function list() {
    var colors = document.getElementById('colors');
    var colors = colors.childNodes.length;
    for (var i = 1; i < broj; i++) {
        var item = colors.childNodes.item(i);
        item.setAttribute("id", i);
        item.setAttribute("onmouseover", "moveover(src)");
        item.setAttribute("alt", "Color");
        item.hspace = "2";
        item.height = "23";
    }
}

function moveover(colorAddress) {
    var source = colorAddress;
    var image = source.slice(0, source.length - 4);
    var start = "url(";
    var extension = ".jpg)";
    var newImage = start.concat(image, extension);
    document.getElementById('image').style.backgroundImage = newImage;
}

window.onload = function() {
    try {
        list();
    } catch …
Run Code Online (Sandbox Code Playgroud)

html javascript error-handling try-catch setattribute

4
推荐指数
1
解决办法
2万
查看次数

如何使用 setAttributedText 为 WKInterface Label 设置对齐方式

我正在尝试为WKInterfaceLabel使用setAttributedText功能设置对齐方式。这是我的代码:

 var paragraphStyle = NSParagraphStyle.defaultParagraphStyle()
 paragraphStyle.alignment = NSTextAlignment.Center
 var attributedDictonary = [NSForegroundColorAttributeName:UIColor.greenColor(), NSParagraphStyleAttributeName:paragraphStyle]
 var attributeString = NSAttributedString(string: "TextAttributed", attributes: attributedDictonary)
 self.titleLabel.setAttributedText(attributeString)
Run Code Online (Sandbox Code Playgroud)

但是我在这条线上遇到了问题:

paragraphStyle.alignment = NSTextAlignment.Center
Run Code Online (Sandbox Code Playgroud)

我有错误: Cannot assign to 'alignment' in 'paragraphStyle'

如何设置对齐WKInterfaceLabel使用setAttributedText

setattribute swift nsparagraphstyle xcode-6.2 wkinterfacelabel

4
推荐指数
1
解决办法
761
查看次数

如何在javascript的setAttribute()方法中向函数添加参数

在 javascript 中,我正在创建新的图像标签,并使用 setAttribute() 方法向它们添加属性,但我发现如果添加一个 onclick 事件并添加一个函数,则无法为其设置参数,如下所示

count = 0; //Will be the number that will go into parameter for function
function start() {
imageTag = document.createElement("IMG"); //Creates image tag
imageTag.setAttribute("src", "popo.jpg"); //sets the image tags source
count++; //as the start function keeps getting called, count will increase by 1 and the parameter for each function in each individual image tag will increase by one
imageTag.setAttribute("onclick", "disappear(count)"); //this will add the onclick attribute with the function disappear() and the parameter …
Run Code Online (Sandbox Code Playgroud)

html javascript parameters function setattribute

4
推荐指数
3
解决办法
1万
查看次数