首页 \ 问答 \ 为html标签添加属性?(Adding attribute to html tag?)

为html标签添加属性?(Adding attribute to html tag?)

由于内部原因,我需要附加一些信息给一些html标签。 例:

<img src="mypic" mycustomvalue="abc">

我可以像这样安全地添加,还是有另一种方式?

谢谢

我目前使用HTML 5

<!DOCTYPE html><html lang="en">

for internal reasons I need to attach some information to some html tag. Example:

<img src="mypic" mycustomvalue="abc">

Can I add safely like that or there is another way?

Thanks

I am currently using HTML 5

<!DOCTYPE html><html lang="en">

原文:https://stackoverflow.com/questions/5419809
更新时间:2023-07-03 18:07

最满意答案

你可以用它

function RunFile(path) {
    WshShell = new ActiveXObject("WScript.Shell");
    WshShell.Run(path, 1, false);
}

<input type="button" value="Run Notepad" onclick="RunFile('c:\windows\notepad.exe');"/>
<input type="button" value="Run Paint" onclick="RunFile('c:\windows\system32\mspaint.exe');"/>

或者采用不同的方法。 为app路径创建变量

var notepad = "c:\windows\notepad.exe";
var paint = "c:\windows\system32\mspaint.exe";

并将它们传递给函数

<input type="button" value="Run Notepad" onclick="RunFile(notepad);"/>
<input type="button" value="Run Paint" onclick="RunFile(paint);"/>

You can use this

function RunFile(path) {
    WshShell = new ActiveXObject("WScript.Shell");
    WshShell.Run(path, 1, false);
}

 

<input type="button" value="Run Notepad" onclick="RunFile('c:\windows\notepad.exe');"/>
<input type="button" value="Run Paint" onclick="RunFile('c:\windows\system32\mspaint.exe');"/>

Or a different approach. Create variables for app path

var notepad = "c:\windows\notepad.exe";
var paint = "c:\windows\system32\mspaint.exe";

and pass them to the function

<input type="button" value="Run Notepad" onclick="RunFile(notepad);"/>
<input type="button" value="Run Paint" onclick="RunFile(paint);"/>

相关问答

更多
  • 有一种方法可以做到这一点: 在rotation=属性中, 0将图像旋转0°, 1将图像顺时针旋转90°, 2将图像旋转180°, 3将图像逆时针旋转90°。 在mirror=属性中, 0不向左和向右反转, 1向左和向右反转。 因此,在上面的示例中, ...
  • 您应该可以使用元素的scrollTop属性来知道某人在页面中向下滚动的距离。 使用包含div元素的onscroll事件在每次滚动时记录该属性的值。 然后使用某种“调整大小后”事件将scrollTop属性设置为最后记录的值。 我还没有跟踪哪个事件做到这一点,但我相信有一些事情会起作用。 You should be able to use the scrollTop property of an element to know how far someone has scrolled down in the p ...
  • 有一种方法 - 我能想到 - 做到这一点,但这真的很痛苦。 和Teemu提到的方式相同。 但是如果你坚持使用单个hta文件,那么这是你的代码: Main HTA This is the ma ...
  • 使用shell()而不是system2() 。 后者期待可执行文件( .exe或.com )或批处理文件( .bat )。 system2()的帮助文件中没有给出此限制,但是在system()的帮助文件中, system2()是一个接口。 确保包含HTA的完整路径。 Use shell() rather than system2(). The latter is expecting an executable (.exe or .com) or batch file (.bat). This restric ...
  • 你可以用它 function RunFile(path) { WshShell = new ActiveXObject("WScript.Shell"); WshShell.Run(path, 1, false); }
    HTA参考 是 IE5 + 是的,.HTA与IE相关联 没有 是 HTA Reference Yes IE5+ Yes, .HTA is associated with IE No Yes
  • 你把一个嵌套的表格放到你的面板上,用这样的2列布局: +------------------------------------------------------------+ | +-------------------+ +----------------------------------+ | | | | | +------------------------------+ | | | | | | | Listbox ...
  • 将hta转换为html并设置为iframe的src Converted hta's to html and set to src for Iframes
  • 发生这种情况,因为“在HTA中有一点IE”在文本输入上按ENTER时会提交表单。 有几种方法可以解决这个问题: 如果您不需要form ,只需将其删除,或用div替换它。 使用函数作为checkEnter并设置: event.cancelBubble = true event.returnValue = false return false This happens, because "a little IE inside HTA" submits the form when pressing ENTER ...
  • 正如评论中所提到的 ,可能的原因是WSF文件中脚本的顺序。 尝试安排它们,以便utils.vbs出现在main.vbs之前,因为它似乎依赖于cutil中的cutil类。