일부 html을 문자열로 구성한 북마크릿은 window.location
과 document.write()
의 조합으로 표시 할 수 있습니까? 여기
은 샘플의 ...
var links = "<html><head><title>Suggested links</title></head><body>";
links += "<p><a href='http://example.com/'>Example Suggested Link</a></p>";
links += "</body></html>";
window.location = 'javascript:document.write("' + links + '");' ;
당신은 당신이 올바른 문자열이 표시됩니다 있는지 확인하기 위해 인용 조심해야하지만, 빠른 테스트 후에는 백 버튼을 존중하는 것 같다 : 브라우저가 페이지를 변경
<html>
<head>
<title>JS Bin Sample bookmarklet</title>
</head>
<body>
<p><a href='javascript:(function(){ var l = "<html><head><title>Does this bookmarklet work?</title></head><body><p>"+ "<a href=\"http://example.com/\">Suggested link: Example.com</a></p>" + "<p><a href=\"http://example.net/\">Suggested link: Example.net</a></p>" + "</bo" + "dy></html>"; window.location = "javascript:document.write(%27" + l + "%27);"; })()'>Sample Bookmarklet - drag me to your toolbar</a></p>
</body>
</html>
웹 사이트를 통해 리디렉션하면 브라우저의 기록에 쉽게 포함될 수 있으므로 다시 돌아가기 쉽습니다. 하나의 정적 HTML + 자바 스크립트 페이지를 호스팅 할 사람이 필요합니다. – joeytwiddle