I am using window.showModalDialog for opening a Pdf file it works in every browser but not working in IE8..it gives an empty modal...
here`s my function
function OpenHippaAgrementStaff(HIPAAFile) {
var mylink = "HipaaDoc/" + HIPAAFile;
window.showModalDialog(mylink, self, 'status:no;resizable:yes;help:no;scroll:no;width:1000;height:600');
return false;}
why dont you try by giving full URL like below,
function OpenHippaAgrementStaff(HIPAAFile) {
var mylink = "FULL_URL_HERE_WHERE_THE_PDF_IS_LOCATED/" + HIPAAFile;
window.showModalDialog(mylink, self, 'status:no;resizable:yes;help:no;scroll:no;width:1000;height:600');
return false;}
use document.location object to get full url
Related
I have the following code,
var newTab;
var url = uniqueUrlEveryTime;
if (!sessionStorage.getItem(url)) {
newTab = window.open(url, '_blank');
sessionStorage.setItem(url, newTab);
newTab.focus();
}
else {
sessionStorage.getItem(url).focus();
}
When the Url is present in the sessionStorage, I am trying to get the newTab object from sessionStorage and set its focus, but it is giving me an error.
What am I doing wrong?
You set the session storage to be the url of the tab. Now you need to run through your tabs and check if the one of them has that url and then set .focus()
Some theoretical code below because I am not sure what your html for the tabs looks like
const tabUrl = sessionStorage.getItem(url)
if(tabUrl === newTab.url){newTab.focus() }
I have a reference to a new window opened with js
var theNewTab="";
theNewTab = window.open(theURL, 'winRef');
then I change the url in the as the user clicks on another link in the parent window using
theNewTab.location.href = targetLink;
theNewTab.focus();
The problem i'm having with chrome that id doesn't throw exception if the the window doesn't exist anymore "closed" unlink FF & IE which im using to open the window again.
try {
theNewTab.location.href = targetLink;
theNewTab.focus();
}catch(err) {
theNewTab = window.open(theURL, 'winRef');
theNewTab.focus();
}
PS: I tried to use "window.open" every time but if the window already open, id does not reload the page or it does but it doesn't re-execute the script I have in document ready I think.
I'm not sure what you need.
<script type="text/javascript">
var theNewTab = null;
function openNewTab(theURL) {
if (theNewTab == null || theNewTab.closed == true) {
theNewTab = window.open(theURL);
} else {
theNewTab.location.href = theURL;
}
theNewTab.focus();
};
// use the function when you need it
$('a').click(function() {
openNewTab($(this).attr('href'));
});
</script>
Is this example helpful for you?
I have a controller that is returning a pdf file, this is temporary save in a local folder. It is possible to open a print dialog directly with out open the pdf file using javascript??
public ActionResult LoadDownloadAndPrint(string Download)
{ return File(System.IO.File.ReadAllBytes(target);)
The file is saved in C:\Windows\Temp\3ac416b7-7120-4169-bc4d-61e105ec197c\output.pdf
I've have tried to used embed tag like in this thread Print PDF directly from JavaScript but did not work I guess because is a local place where the file is stored.
After a lot of researching finally get it using iframe. This code was very helpful http://www.sitepoint.com/load-pdf-iframe-call-print/
I have an empty hidden iframe in my view.
This is working in Chrome, FF, but not in IE
Search.openPrintDialog = function () {
var printJobIds = $("input:checkbox[name='Print']:checked").map(function () { return this.value; }).get().join(',');
if (printJobIds.length > 0)
{
JSUtil.BlockUI();
print('/' + JSUtil.GetWebSiteName() + '/Search/LoadDownloadAndPrint?Print=' + printJobIds)
}
return false;
}
function print(url) {
var _this = this,
iframeId = 'iframeprint',
$iframe = $('iframe#iframeprint');
$iframe.attr('src', url);
$iframe.load(function () {
_this.callPrint(iframeId);
});
}
//initiates print once content has been loaded into iframe
function callPrint(iframeId) {
var PDF = document.getElementById(iframeId);
PDF.focus();
PDF.contentWindow.print();
JSUtil.UnBlockUI();
}
I have got a problem with a script on a website I am developing. It works fine in Safari, Opera and Chrome, but it doesn't work in firefox.
As you click a link, I try to load the div #contain from internal links to an overlay div, which then is unhidden. All this is working fine in the browsers I have mentioned above, but it wont work in firefox, the click function just opens the link (reloads the page) as it would normally do.
Any Ideas why it does not work in Firefox? Anything that I am missing?
$(document).ready(function(){
var $ov = $('.overlay'),
$tp = $('#transparent'),
URL = ' ',
siteURL = "http://" + top.location.host.toString(),
$internal = $("a[href^='"+siteURL+"'], a[href^='/'], a[href^='./'], a[href^='../'], a[href^='#']:not('.no')"),
hash = window.location.hash,
$el, $allLinks = $("a");
$tp.hide();
$ov.hide();
$tp.click(function(){
$ov.empty();
$tp.hide();
$ov.hide();
});
if (hash) {
$ov.show();
$tp.show();
hash = hash.substring(1);
URL = hash + " #contain";
$ov.load(URL);
};
$internal.each(function(){
$(this).attr("href", "#" + this.pathname);
}).click(function(){
$tp.show();
$ov.show();
$el = $(this);
URL = $el.attr("href").substring(1);
URL = URL + " #contain",
$ov.load(URL);
});
});
I think you are missing preventDefault in your click function. This tells jQuery/javascript to not follow the default action which in your case would be following wherever the link is pointing to in HREF.
Instead of
$tp.click(function(){
$ov.empty();
$tp.hide();
$ov.hide();
});
It should be
$tp.click(function(e){
e.preventDefault;
$ov.empty();
$tp.hide();
$ov.hide();
});
instead of
$tp.click(function(
try
$(document).on('click','#transparent',function(event){
//do whatever you want to do
});
Try to change the default behaviour of the browser :
(event.preventDefault) ? event.preventDefault() : event.returnValue = false;
var windowUrl = "";
var windowName = "mywin";
var w = window.open(windowUrl, windowName, windowSize);
w.document.write(html);
w.document.close();
This is tied to onclick. I do not want to write or close or even open if window exists (maybe refocus instead). I found some examples, but they do not seem to "work" (or do what I think I need.)
Try the following:
<script type="text/javascript">
function loadUniquePage(page)
{
if (opener && !opener.closed) {
opener.focus();
} else {
var myWin = window.open(page,'','width=800,height=600');
opener = myWin;
}
}
</script>
also take a look at this question - JavaScript window.open only if the window does not already exist
also take a look on the link provided by #Aram Kocharyan:
https://developer.mozilla.org/en/DOM/window.closed