views:

20

answers:

1

Hello, I'm writing this bookmarklet in Javascript, which is also calling some JQuery objects. The goal here is to pull the page title, URL and any currently selected text, then fill them into fields on the target page.

The problem is that it only works when I'm on the page with the fields I'm trying to fill in! I've tried everything but I'm at a loss. Can anyone help me out? Here's the code:

javascript: (function() {
title = document.title;
url = document.URL;
text = document.getSelection();
w = window.open('My site');
w.onload = function run() {
    w.$('#id_title').val(title);
    w.$('#id_url').val(url);
    w.$('#id_description').val(text);
}
})();

Any help is greatly appreciated, as I'm a a js novice.

A: 

I believe you are hitting a X-site scripting security measure. A page from site A can't modify a page from Site B.

And/or you are using jQuery to set values in the popup window... is jQuery loaded in the main source window? or do you load it yourself?

scunliffe
Yeah, you're right about that. I was approaching the problem the wrong way. I'm re-doing the bookmarklet by instead sending GET data to the back-end, then copying into the fields when the page loads.
Streetfights