I am trying to use the "Save Page Feature" to make a bookmarklet that allows a user to push a page to the Internet Archive with a single click.
From what I've gathered, if I post to
http://web.archive.org/save/fullURI
It'll save the page at fullURI
(i.e. fullURI=http://www.google.com
with all the slashes)
So I wrote the following bookmarklet (white space added for clarity and javascript:
removed to force syntax highlighting)
(function(){
var u='http:\/\/web.archive.org\/save\/'+encodeURI(window.location.href);
var w = window.open('', '');
w.document.write('<script>
var u = \'' + u +'\';
var x = new XMLHttpRequest();
x.open(\'POST\',u,true);
x.send();
<\/script>')})();
Fiddle here.
So everything swims along, opens a new page, tries a post, and boom, CORS error (oddly from the parent page, not the new window).
Funnily enough I also found that if I open a new window, and paste the URI in, it works, but if I do a window.open(URI)
it says please try a POST
.
So at this point I'm open to ideas. Is there a good, cross-browser bookmarklet solution to this? Did I overlook something simple trying to reinvent the wheel?
FWIW I'm on Chrome 30 when I try pasting the URI.