js怎么加载另一个页面的代码?

JavaScript09

js怎么加载另一个页面的代码?,第1张

html通过iframe把2.html加载进来,然后通过iframe.contentWindow.A()就可以;

1、必须两个页面在同一个域。

2、将两个页面的js拿出来,保存为a.js。

3、在两个页面里都引用这个a.js,那么里面的函数在两个页面里都能使用了。

1使用 window.onload = function(){

//你要写的代码;

//又或者你要加载的js代码 document.write("<script type/javascript src='xxx.js'><script>") }

2 把js代码写在最后面,如:<html>...</html><scirpt>....</sciprt>

$scope.on_impersonate_success = function(response) {//$window.location.reload()//This cancels any current request

$location.path('/')//This works as expected, if path!= current_path}$scope.impersonate = function(username) {

return auth.impersonate(username). then($scope.on_impersonate_success, $scope.on_auth_failed)}