views:

79

answers:

1

I have the following javascript bookmarklet which opens a new popup window with a facebook post page in side of it.

javascript:var d=document,f='http://www.facebook.com/share',l=d.location,e=encodeURIComponent,p='.php?src=bm&v=4&i=1261526047&u='+e(l.href)+'&t='+e(d.title);1;try{if (!/^(.*\.)?facebook\.[^.]*$/.test(l.host))throw(0);share_internal_bookmarklet(p)}catch(z) {a=function() {if (!window.open(f+'r'+p,'sharer','toolbar=0,status=0,resizable=1,width=626,height=436'))l.href=f+p};if (/Firefox/.test(navigator.userAgent))setTimeout(a,0);else{a()}}void(0)

I just add that code into the URL of a shortcut link in my browser and it opens the facebook post page and passes the URL and some info about the page I am on to it.

I need to do a much simpler task. I need to get the URL of the page I am on and either open a new tab or even just use the tab I am in and then open a link like this

http://mydomain.com/labs/iframe_header.php?url= PUT THE CURRENT PAGES URL RIGHT HERE  

As you can see I just need to make a bookmarklet that will take the page I am on and pass it into my sites page. Can anyone help me, I don't know much javascript at all, would greatly appreciate any help.

+1  A: 
javascript: location.href = 'http://mydomain.com/labs/iframe_header.php?url=' + escape(location.href);

This will open in a new window, which will use a new tab if your browser is set up that way:

javascript: window.open('http://mydomain.com/labs/iframe_header.php?url=' + escape(location.href));
Jeff B
That is perfect! Do you know how I could possibly make it open in a new tab when I click it from a link?
jasondavis
See edit. You can't control tabs with javascript alone (yet). But if you use window.open, and you have your browser set to open new windows in a tab, this will do what you want.
Jeff B