html中的js代码怎么放进js文件中,格式
发布网友
发布时间:2022-05-01 04:42
我来回答
共1个回答
热心网友
时间:2022-04-22 13:35
function addItem() {
var obj = new ActiveXObject("WScript.Shell");
obj.RegWrite("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\TestValue", "1", "REG_SZ");
document.writeln("Written successfully</br>");
var testValue = obj.RegRead("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\TestValue");
document.writeln("Read successfully</br>");
document.writeln("The value of TestValue is "+testValue);
}
保存为js文件,在html文件中写入代码<script type="text/javascript">
function addItem() {
var obj = new ActiveXObject("WScript.Shell");
obj.RegWrite("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\TestValue", "1", "REG_SZ");
document.writeln("Written successfully</br>");
var testValue = obj.RegRead("HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer\\TestValue");
document.writeln("Read successfully</br>");
document.writeln("The value of TestValue is "+testValue);
}
保存为js文件,在html文件中写入代码包含js文件,并且在body中<body onload="addItem()">就可以了