为什么我的模态窗口空白?

时间:2013-10-30 16:12:22

标签: javascript jquery greasemonkey simplemodal userscripts

我是品牌 javascript的新手,并且对于遇到问题并不感到惊讶。这是我的用户名:

// ==UserScript==
// @name       Open Modal-External Page-Iframe
// @version    0.1
// @match      http://barackobamaisyournewbicycle.com/
// @require http://code.jquery.com/jquery-latest.js
// @require https://simplemodal.googlecode.com/files/jquery.simplemodal-1.4.4.js
// ==/UserScript==

$(document).ready(function() {  
  $('body').append('<input type="button" value="test-modal-button" id="CP">');
  $("#CP").css("position", "fixed").css("top", 25).css("left", 0);
  $('#CP').click(function(){ 
      alert('testmodal');
      var src = "http://365.ericmmartin.com/";
      $.modal('<iframe src="' + src + '" height="450" width="830" style="border:0">', {
          closeHTML:"",
          containerCss:{
              backgroundColor:"#fff", 
          borderColor:"#fff", 
          height:450, 
          padding:0, 
          width:830
          },
          overlayClose:true
      });
   });
});

问题

当我导航到http://barackobamaisyournewbicycle.com时,我会在左上方看到我的按钮[test-modal-button],当我点击时,会出现模态窗口,但http://365.ericmartin.com/未在该模式窗口中加载,模态窗口保持空白。刚才我在其间放了一个alert('testmodal');语句,这样我知道单击按钮时我会触及该代码,但这只是出于调试目的。

我直接从

中提取了这个例子

http://www.ericmmartin.com/projects/simplemodal/

at

“//使用iframe显示外部页面”;大约3/4的页面。


编辑:

我将这个问题的@match网站更改为我能找到的最简单的网页,但实际在barackobamaisyournewbicycle.com上尝试了它,它开始工作了。必须与我正在测试的其他网站有关吗?虽然这对我来说没有多大意义。既然我已经在这个问题上付出了一些努力,那么有什么建议可以改进我的实施吗?

0 个答案:

没有答案