Answer the question
In order to leave comments, you need to log in
Could not load the source for javascript error in firefox when opening a popup, what's the problem?
There is a functionality that allows you to click on a link to open a PDF file in a new window and print it out. In chrome, everything works fine, unlike firefox.
Code and usage:
var popupURL = "";
function ShowPopup() {
var popup = window.open(popupURL, null, 'toolbar=0, location=0, directories=0, status=0, menubar=0, scrollbars=0, resizable=0, width=600, height=800');
popup.focus();
popup.print();
}
<a href="javascript: popupURL='{% url "exchange" obj.pk %}?pdf=1'; ShowPopup();" title="{% trans "pdf" %}">pdf</a>
Error loading source:
Could not load the source for javascript:%20popupURL='/exchange/234?pdf=1';%20ShowPopup();.
[Exception... "Component returned failure code: 0x80040111 (NS_ERROR_NOT_AVAILABLE) [nsIChannel.asyncOpen]"
Answer the question
In order to leave comments, you need to log in
When everyone understands that javascript in links is bad, bad, bad.
That opening new windows when it's not needed is bad, bad, bad.
What to write onclick is...
In addition, the PDF will be opened by a plug-in built into the browser, which (incredibly!) has the functions of save, scale, print, and a couple more. Why do they need to be duplicated?
<a href="и_тут_реальная_ссылка_на_pdf" rel="alternate" type="application/pdf">pdf</a>
Remove space after javascript:
HTML
JS
function ShowPopup(url) {
var popup = window.open('/exchange/' + url + '?pdf=1', null, 'toolbar=0,
location=0, directories=0, status=0, menubar=0, scrollbars=0,
resizable=0, width=600, height=800');
popup.focus();
popup.onload = function(){
popup.print();
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question