gpt4 book ai didi

javascript - 从书签打开页面,但是,让它像一个模态窗口?

转载 作者:行者123 更新时间:2023-11-30 10:44:54 27 4
gpt4 key购买 nike

我正在使用一个小书签,它(显然)可以被用户在任何地方调用:

javascript:(function(){window.open('http://*****.com/***.html?url=
'+encodeURIComponent(window.location.href),'my_page_name',
'left=200,top=200,width=480,height=500,personalbar=0,
toolbar=0,scrollbars=1,resizable=1')})()

我怎样才能使它像模态窗口一样,这意味着没有丑陋的浏览器窗口边框 - 我应该在书签 URL 中使用 jquery 或类似的东西吗?如果是,怎么做?

最佳答案

您可以使用 Firebug Lite 的方法使用。
基本上,当您单击书签时,您会将一个外部 JS 文件插入到您的页面中。

<a href="javascript:(function(F,i,r,e,b,u,g,L,I,T,E){if(F.getElementById(b))return;E=F[i+'NS']&&F.documentElement.namespaceURI;E=E?F[i+'NS'](E,'script'):F[i]('script');E[r]('id',b);E[r]('src',I+g+T);E[r](b,u);(F[e]('head')[0]||F[e]('body')[0]).appendChild(E);E=new%20Image;E[r]('src',I+L);})(document,'createElement','setAttribute','getElementsByTagName','FirebugLite','4','PATH_TO_JS ','PATH_TO_ICON','BASE_URL','#startOpened');">My bookmark</a>

只需将 BASE_URLPATH_TO_JSPATH_TO_ICON 更改为您需要的内容即可。
另外,不要忘记 BASE_URL 中的 “http://”,除非您想使用相对路径。

您的外部 JS 文件可以包含一个脚本,该脚本将一个元素添加到悬停在其他元素之上的页面。我建议使用 Twitter Bootstrap 中的 CSS弄清楚如何制作可靠的模态窗口。

编辑 --

为了帮助您,我写了 a small demo .它由 2 个文件组成:

  • bookmark.html - 修改了 firebug 代码来创建动态添加脚本的书签
  • bookmark.js - 使用 iframe 创建模式

书签.html

<a href="javascript:(function(F,i,r,e,b,u,g,L,I,T,E){if(F.getElementById(b))return;E=F[i+'NS']&&F.documentElement.namespaceURI;E=E?F[i+'NS'](E,'script'):F[i]('script');E[r]('id',b);E[r]('src',I+g+T);E[r](b,u);(F[e]('head')[0]||F[e]('body')[0]).appendChild(E);E=new%20Image;})(document,'createElement','setAttribute','getElementsByTagName','FirebugLite','4','bookmark.js','','http://www.bijtel.com/stackoverflow/bookmark/','#startOpened');">Bookmark</a>

书签.js

(function() {
var script;

if(!window.jQuery) {

script = document.createElement("script");
script.type = "text/javascript";
script.src = "https://ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js";
document.body.appendChild(script);

}

(function check_if_loaded() {

if(!window.jQuery) {

setTimeout(check_if_loaded, 50);

} else {

(function($) {

var
$dark_bg = $('<div></div>').css({'z-index': '1000', 'background-color': '#000000', 'opacity': '0', 'position': 'absolute', 'width': '100%', 'height': '100%'}),
$iframe = $('<iframe></iframe>').css({'width': '100%', 'height': '100%', 'border': 1, 'overflow': 'hidden'}).prop({'src': 'http://bijtel.com/cv/', 'width': '100%', 'height': '100%', 'scrolling': 'no'}),
$close = $('<div></div>').css({'position': 'absolute', 'top': 0, 'right': 0, 'padding': '5px 10px', 'cursor': 'pointer', 'color': '#ffffff', 'font-size': '10pt', 'font-family': 'verdana'}).html('close &times;');
$modal = $('<div></div>').css({'z-index': '1010', 'background-color': '#ffffff', 'opacity': '0', 'position': 'absolute', 'top': '10%', 'left': '10%', 'width': '80%', 'height': '80%', 'box-shadow': '7px 7px 5px #333'}).append($close, $iframe);

$('body').css({'padding': 0, 'margin': 0}).prepend($dark_bg, $modal);

$dark_bg.animate({'opacity':0.5}, 400);

$modal.animate({'opacity':1}, 400);

$close.on('click', function() {
$dark_bg.animate({'opacity': 0}, 400, function(){ $dark_bg.remove(); });
$modal.animate({'opacity': 0}, 400, function(){ $modal.remove(); });
});

}(window.jQuery));

}

}());

}());

演示地址:http://bijtel.com/stackoverflow/bookmark/

关于javascript - 从书签打开页面,但是,让它像一个模态窗口?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8963688/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com