...

View Full Version : How to make this bookmarklet open in new window



SayItAintSo
05-21-2009, 07:08 PM
I need this bookmarklet (below) to open in a new window and display the info there. It needs to work in both FF and IE. It would be in one line in the bookmarklet but I expanded it for readability. It should work against our site:www.mysanantonio.com (http://www.mysanantonio.com)

javascript:
var adBookmarkletData=[];
adBookmarkletData.push('<html><head><title>MYSA Yahoo! APT Debugger</title></head><body><center><div style=\"background:#ccc;color:#000;width:350px;text-align:left;padding:15px;border:2px #000;\">');
adBookmarkletData.push('<b>MYSA Yahoo! APT Debugger:</b><br /><hr />');
adBookmarkletData.push('<b>URL:</b> '+document.location.href+'<br />');
adBookmarkletData.push('<b>Pub ID:</b> '+window.yld_mgr.pub_id+'<br />');
adBookmarkletData.push('<b>Site Name:</b> '+window.yld_mgr.site_name+'<br />');
adBookmarkletData.push('<b>Content Topic ID List:</b> '+window.yld_mgr.content_topic_id_list+'<br />');
adBookmarkletData.push('<b>Site Section Name List:</b> '+window.yld_mgr.site_section_name_list+'<br />');
for(i in window.yld_mgr.slots){
adBookmarkletData.push('<b>AD:</b> ('+i+') <b>Category:</b>('+window.yld_mgr.slots[i].cstm_content_cat_list+')<br />');
};
adBookmarkletData.push('</div></center></body></html>');
function createAptDebugger(){
for (i in adBookmarkletData){document.write(adBookmarkletData[i]);}
};
void(createAptDebugger());

This had been suggested and I tried it but it only opens an empty window in IE and an empty tab in FF. I need it to open a new window in both:
This did not work:

var adBookmarkletData=[
'<html><head><title>MYSA Yahoo! APT Debugger</title></head><body><center><div style=\"background:#ccc;color:#000;width:350px;text-align:left;padding:15px;border:2px #000;\">',
'<b>MYSA Yahoo! APT Debugger:</b><br /><hr />',
'<b>URL:</b> '+document.location.href+'<br />',
'<b>Pub ID:</b> '+window.yld_mgr.pub_id+'<br />',
'<b>Site Name:</b> '+window.yld_mgr.site_name+'<br />',
'<b>Content Topic ID List:</b> '+window.yld_mgr.content_topic_id_list+'<br />',
'<b>Site Section Name List:</b> '+window.yld_mgr.site_section_name_list+'<br />'];
for(i in window.yld_mgr.slots){
adBookmarkletData.push('<b>AD:</b> ('+i+') <b>Category:</b>('+window.yld_mgr.slots[i].cstm_content_cat_list+')<br />');
};
adBookmarkletData.push('</div></center></body></html>');
function createAptDebugger(){
var pu=window.open("");
pu.onload=function(){
pu.document.write(adBookmarkletData.join(""));
}
};
void(createAptDebugger());
I've been trying different things but no joy. Thank in advance for looking at this,
Regards,

adios
05-22-2009, 12:58 AM
Try this:


function createAptDebugger(){
pu=window.open("javascript:adBookmarkletData.join('')", "", "");
};
void(createAptDebugger());

[untested]

You can add window properties in the 3rd argument to open().
By the time open() returns, the window is already open and, with only a blank document to load, it's probably too late to set the onload handler. A javascript: url should load the string.

SayItAintSo
05-22-2009, 03:58 PM
The inspiration for this was from a bookmarklet that actually sources another page.

It looks like this:


javascript:
void(window.open(%22%22,%22stats_debugger%22,%22width=600,height=600,location=0,menubar=0,status=1,t oolbar=0,resizable=1,scrollbars=1%22).document.write(%22<script language=\%22JavaScript\%22 src=\%22https://sitecatalyst.omniture.com/sc_tools/stats_debugger.html\%22></%22+%22script>%22 + %22<script language=\%22JavaScript\%22>window.focus();</script>%22));

I may try that approach too. The reason I did not do it was that the method I used seemed so close and I thought it was a matter of just getting it to open in a new browser. I am still not clear on the mechanics of opening a new window or tab that actually has code from the previous one.???

BTW I am grateful for your response.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum