请在Chrome浏览器中查看我的代码,如果点击刷新,系统会提示您选择2个选项.
- 离开这个页面和
- 保持此页上
当我点击2.停留在此页面按钮时,它必须激活我的自定义功能displayMsg()
谁能为我提供解决方案?
<script type="text/javascript">
function displayMsg() {
alert('my text..');
}
</script>
<script type="text/javascript">
window.onbeforeunload = function(evt) {
var message = 'Please Stay on this page and we will show you a secret text.';
if (typeof evt == 'undefined') {
evt = window.event;
}
if (evt) {
evt.returnValue = message;
return message;
}
trace(evt);
}
</script>
Run Code Online (Sandbox Code Playgroud) 我有一个String,它从其他服务器动态获取其值.字符串的值是
$string1 = '<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.microsoft.com/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<AuthenticateUserResponse xmlns="http://microsoft.com/xml/namespace/2012/04">
<Authenticator>AE1001</Authenticator>
</AuthenticateUserResponse>
</soap:Body>
</soap:Envelope>';
Run Code Online (Sandbox Code Playgroud)
我的问题是,通常我们使用*$ xml = simplexml_load_file("test1.xml");*来加载XML文件,但在我的要求中它是一个String,我怎样才能读取这个String值并提取子节点及其值?例:
<Authenticator> and its value "AE1001" ?
有没有办法将其放入数组?这样我就可以轻松打印出它的节点值了吗?