Bookmarklet In New Window - javascript

So I've got a bookmarklet which should open up a page in a new window.
javascript:window.open('http://timetableapp.com/TimeTable/bookmarklet/index.html','TimeTable%20Timer','status=no,directories=no,location=no,resizable=no,menubar=no,width=400,height=210,toolbar=no');
The code works perfectly in Safari, Firefox, and Chrome; but as expected IE (7 and 8) is causing problems. IE gives me a useless error when I open the bookmarklet, and no window opens.
I've tried to editing the bookmarklet so that it appends the page with a script tag. Then inside the script tag the window.open() code is added, or it accesses the script (which contains the window.open() ) [I've tried it both ways]
I'm at a loss now.
Anyone have any idea how to get the page to popup in IE (preferably with code that works in Safari, FF, and Chrome too)?
Thanks,
EDIT:
The final code I ended up with:
javascript:(function(){ window.open('http://timetableapp.com/TimeTable/bookmarklet/index.html','TimeTableTimer','status=no,directories=no,location=no,resizable=no,menubar=no,width=400,height=210,toolbar=no'); })();

You can't have %20 or spaces in your window name. The name is for referring to the window again later in code.
Try:
javascript:window.open('http://timetableapp.com/TimeTable/bookmarklet/index.html','TimeTableTimer','status=no,directories=no,location=no,resizable=no,menubar=no,width=400,height=210,toolbar=no');

Related

javascript popup firing only in chrome

This is some js in one of my views:
var $link = 'info';
I want to pop open a new small window when someone clicks on the details of an item on my page. The code above renders this html on the page:
info
which is only working in chrome (no popup blockers are enabled in IE9 or FF ) what am i doing wrong here?
EDIT
ok ive updated the markup same issue only works in chrome,
info
EDIT #2
Ok think ive got the markup kinda fixed FF and IE are now opening my popup but when they do the parnt window content is replaced with [object] in IE and [Window Object] in FF.... Now what the heck is going on?
info
Probably because you are not escaping double quotes.
Modified:
info
ok so this article pointed me to my solution. Popup errors Object Window
Here is my new markup:
var $link='info';
Here is how it renders:
info
And it works perfect in all 3 browsers.

Javascript bookmark stopped working in Firefox 13

In Firefox version 13, bookmarklets (bookmarks with a javascript: URL, e.g. javascript: alert("it works") stopped working. Is there any solution to use javascript: bookmarks in Firefox 13?
This is a consequence of Bug 728313 - Using a bookmark keyword to a bookmarklet fails on new tabs, also Bug 739387 - Aurora 13a New Tab display doesn't allow javascript bookmarks to be selected . This bug affects Firefox 13 onwards.
As a consequence of the fix to bug 723808, javascript: bookmarks are disabled in a just-created new tab. If you first load almost any URL, including about:blank, then a Javascript bookmark will work in that tab.
Note that this is about Javascript bookmarks (bookmarklets). You cannot use this workaround to load javascript: URLs typed directly in the location bar. These have been disabled since Firefox 6, as a consequence of bug 656433 (phishing of javascript: URLs). Bug 680302 is a feature request to allow turning javascript: URLs back on through a preference. Valadrem has written the InheritPrincipal extension to remove this restriction (I haven't tested it). You can still type and run Javascript code in the Scratchpad (press Shift+F4, type code, press Ctrl+R).
There are restrictions on the Javascript you can run from the URL bar or from a bookmark. For example, since Firefox 7, you cannot resize the window (consequence of the fix to bug 565541); the services.sync.prefs.sync.dom.disable_window_move_resize controls this restriction.
NOTE: this solution no longer appears to work as of FF41. See JS Bookmarklets stopped working in Firefox 41.
If you first load almost any URL, including about:blank, then a
Javascript bookmark will work in that tab.
Since Firefox's default behavior for new tabs is about:newtab, which is nothing, and bookmarklets only run once something is loaded, you can do the following to set a default page, and then run bookmarklets:
open about:config
find browser.newtab.url
double-click and change from about:newtab to about:blank (or URI of your choice)
Ctrl-T and run bookmarklets in new tabs!
I have been able to use bookmarklets in recent versions of firefox (I just tested a few on FF23). Two suggestions:
Replace spaces with %20. For instance, try your example bookmarklet code with javascript:alert("it%20works") instead of javascript:alert("it works")
If this isn't enough, enclose the whole bookmarklet inside an anonymous function, so in your example, you'd write javascript:((function(){alert("it%20works");})())

After window.open, can't print in Safari for Mac

I create a secondary browser window with Javascript code, using the window.open function, and fill it programmatically with some HTML content. It works well for all browsers that my application supports except for one: Safari on Mac. In fact, the window itself is OK but the print command is disabled. Does anybody have an idea why? I should mention that the main reason to show this window is to allow the users to print some data. I guess I could implement a "Print" button in the page but I would prefer not to (and it may not work either, but I haven't tried it).
Here is a simplified example of the code that I use to create the HTML content:
var pp = window.open("", "_blank");
pp.document.writeln("<html>");
pp.document.writeln("<head>");
pp.document.writeln("<title>");
pp.document.writeln("Hello");
pp.document.writeln("</title>");
pp.document.writeln("</head>");
pp.document.writeln("<body>");
pp.document.writeln("The body");
pp.document.writeln("</html>");
pp.document.close();
I tried variations around that code, without any success. My tests are done with Safari 5.1 on Mac OS X 10.6.8. Any help is welcome!
Have the window print itself:
Before your </html> add:
pp.document.writeln("<script type='text/javascript'>window.print()</script>");

Page not loading in IE

I just made some CSS changes to a page and all works perfect in firefox safari, chrome but when i view it in IE there is nothing. I mean just a blank page
http://posnation.com/pos_support/aldelo_training_dvd
Also this is a miva site
try validating your html. You also don't have an end title tag.
Close title tag.
It looks like the tag in the page head isn't closed properly (line 4). FF and Chrome often fix this sort of error for you as they render the page, IE isn't on this occasion.

IE won't load PDF in a window created with window.open

Here's the problem, which only occurs in Internet Explorer (IE). I have a page that has links to several different types of files. Links from these files execute a Javascript function that opens a new window and loads the specific file. This works great, unless the file I need to open in the new window is a PDF in which case the window is blank, even though the URL is in the address field. Refreshing that window using F5 doesn't help. However, if I put the cursor in the address field and press <enter> the PDF loads right up.
This problem only occurs in IE. I have seen it in IE 7 and 8 and am using Adobe Acrobat Reader 9. In Firefox (PC and Mac) everything works perfectly. In Chrome (Mac), the PDF is downloaded. In Safari (Mac) it works. In Opera (Mac) it prompts me to open or save. Basically, everything probably works fine, except for IE.
I have searched for similar problems and have seen some posts where it was suggested to adjust some of the Internet Options on IE. I have tried this but it doesn't help, and the problem wasn't exactly the same anyway.
Here's the Javascript function I use to open the new window.
function newwin(url,w,h) {
win = window.open(url,"temp","width="+w+",height="+h+",menubar=yes,toolbar=yes,location=yes,status=yes,scrollbars=auto,resizable=yes");
win.focus();
}
You can see that I pass in the URL as well as the height, h, and width, w, of the window. I've used a function like this for years and as far as I know have never had a problem.
I call the newwin() function using this.
document.pdf
(Yes, I know there are other, better ways than using inline JS, and I've even tried some of them because I've run out of things to try, but nothing works.)
So, if anyone has an idea as to what might be causing this problem, I'd love to hear it.
try:
function newwin(url,w,h) {
var win = window.open("","temp","width="+w+",height="+h+",menubar=yes,toolbar=yes,location=yes,status=yes,scrollbars=auto,resizable=yes");
win.location.href = url;
win.focus();
}
I have solved this problem with an invisible iframe
<div id="iframe" style="display: none">
<iframe id="frm" style="display: none"></iframe>
</div>
And this logic here (using jquery):
if ($.browser.msie && ($.browser.version < 9.0)) {
frm.location.href = href;
}
else {
window.open(href);
}
The behaviour in my case is exactly as if the document was opened in a popup, as I'm using
Content-Disposition: attachment; filename="document.pdf"

Categories

Resources