Search code examples
javascriptbookmarklet

Display a temporary web page with javascript


I'm making a bookmarklet that scrapes a web page and construct a list of URLs that I want to be diplayed instead of the current web page. How to you create a temporary web page and viewing it in the browser?

This is what I've got so far:

var urls = myUrlScraper(window.location.pathname);
var tempPage = "<html>" + urls + "</html>";
window.location = tempPageUrl; // How to do this?

Solution

  • You could open a new window and write your HTML to it.
    Something like:

    var urls = myUrlScraper(window.location.pathname);
    var tempPage = "<html>" + urls + "</html>";
    
    var w = window.open(''); 
    w.document.write(tempPage);