是否可以在同一个html页面上将复杂的javascript嵌入onclick

时间:2016-03-22 01:17:42

标签: javascript html

我需要将一段html代码注入远程服务器。 html代码包含图像和指向我服务器中托管的图像位置的直接链接。例如

<img src="path.to.my.server.gif" >

当用户点击我的图片时,我想向我的服务器发送2个跟踪像素(一个http调用)并将它们重定向到另一个页面。

<img onClick="do_some_javascript_here">

通常,如果我服务网页,我可以完全控制我的js文件,这项工作将是微不足道的,例如在角度

<img ng-click="doSomeJavascipt()>   

 $scope.doSomeJavascript = function() {

        $http.get(pixel_url_1)
          .then(function(){
              $http.get(pixel_url_2)
                .then(function(){
                  $window.location.href = some_url;
                })
          })
          .catch(); 
    }

但由于我没有为该页面提供服务,我不知道该怎么做。

任何建议都会很感激

由于

0 个答案:

没有答案
相关问题