小编Me *_* 4U的帖子

Javascript当我们在Chrome中选择Stay on Page时,如何调用函数

请在Chrome浏览器中查看我的代码,如果点击刷新,系统会提示您选择2个选项.

  1. 离开这个页面和
  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)

html javascript jquery

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

PHP如何使用PHP读取字符串中的XML子节点值?

我有一个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" ?

有没有办法将其放入数组?这样我就可以轻松打印出它的节点值了吗?

php xml

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

标签 统计

html ×1

javascript ×1

jquery ×1

php ×1

xml ×1