Exploring the Printing Options in Opera using ASP.NET

When using JavaScript, I encountered an issue where the print dialog box would not appear. The new window would open successfully, but the print dialog was missing. This problem only occurred in Opera, while IE, Chrome, and Mozilla worked fine. I have researched the usual timeout issues related to Opera and tried multiple solutions, but none of them seem to work.

Does anyone have any idea what the solution might be?

var windowUrl = 'about:blank';
var UserLoggedIn = $("#lblUser").text()
var now = new Date();
var strDateTime = [
    [AddZero(now.getDate()), AddZero(now.getMonth() + 1), now.getFullYear()].join("/"), [AddZero(now.getHours()), AddZero(now.getMinutes())].join(":"), now.getHours() >= 12 ? "PM" : "AM"].join(" ");
var Database = 'ProductionDatabase';
var windowName = 'Report';
var AuditPrintDetailEverypage = UserLoggedIn + ' Time : ' + strDateTime;
var AuditPrintDetailLastPage = '      Report ' + ' Source Database: ';
var WinPrint = window.open(windowUrl, windowName, 'left=300,top=300,right=500,bottom=500,width=1000,height=500,scrollbars=1');
WinPrint.document.write('<' + 'html' + '><head><link href="assets/css/Print.css" rel="stylesheet" type="text/css" /><title>' + AuditPrintDetailEverypage + '</title> </head><' + 'body  style="background:none !important"' + '>');
WinPrint.document.write(printContent.innerHTML);
WinPrint.document.write('          ' + AuditPrintDetailLastPage);
WinPrint.document.write('<' + '/body' + '><' + '/html' + '>');
WinPrint.document.close();

if (window.opera) {
    window.onload = function () {
        window.setTimeout(function () {
            window.print;
        }, 500);
    }
} else {
    WinPrint.focus();
    WinPrint.print();
    WinPrint.close();
}

Answer №1

It appears that the () is crucial for Opera, despite what certain websites may suggest. Hopefully, this information proves useful to others. Credit goes to the individuals mentioned above.

if (window.opera) {

    WinPrint.onload = function () {
        WinPrint.setTimeout(function () {
            WinPrint.print();
        }, 500);
    }

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Managing state in React for a nested object while still maintaining the data type of the

Exploring the question further from this particular query Updating State in React for Nested Objects The process of updating nested state involves breaking down the object and reconstructing it as shown below: this.setState({ someProperty: { ...this.stat ...

How can I extract the domain name using a regular expression in JavaScript?

I am struggling with creating a regular expression to extract the main domain name from a URL. The URLs I have are: http://domain.com/return/java.php?hello.asp http://www.domain.com/return/java.php?hello.asp http://blog.domain.net/return/java.php?hello.as ...

Struggling to locate a control within a FormView from the code-behind section

I am attempting to access a control in the code-behind in order to add items to a drop-down list. Specifically, I am trying to retrieve the Role Groups to add to the drop-down list in the code-behind. Protected Sub Page_Load(ByVal sender As System.Object, ...

converting an array filled with key-value pairs into JSON using c#

Hey there, I'm diving into C# for the first time and it's already causing me some serious confusion. I know this may seem like a simple task to many, but after spending over an hour searching online, I still can't figure it out. All I want ...

Leveraging IE conditional comments for including CSS or JavaScript files can lead to an increase in the number of HTTP

Our web designer has implemented special pages for Internet Explorer by using IE-specific comments. This means that certain stylesheets are only loaded if the user is using a specific version of IE: <!--[if lt IE 7]> <link type="text/css" rel="st ...

Utilizing a Function Across Controllers in AngularJS: A Guide

When developing my angularjs application, I decided to create two separate modules - 'home' and 'templates'. I am now faced with the challenge of utilizing functions from one module in the other. Here's how I approached it: Modu ...

Developing Adobe plug-ins by utilizing the C# programming language

My understanding is that in order to develop Adobe plugins, one must utilize C++ and the Adobe SDK. Is it feasible to use C# and integrate it with the Adobe SDK to create Adobe plugins? ...

Error: Unable to access the 'address' property of a null object

I am a beginner in the realm of react and have encountered an issue with my app, which is a simple e-commerce platform. The problem arises when I try to enter the shipping address during the checkout process, as it throws an error. TypeError: Cannot read ...

Tips for setting up Code Coverage in a Cypress environment for testing a NextJS build simultaneously

We are currently exploring the possibility of integrating code coverage into our setup utilizing cypress and nextjs. Within our cypress configuration, we utilize the next() function to mimic backend requests within nextjs. The cypress.config.ts file is st ...

What are the steps to verify if an iframe is lacking content?

I have two different codes: one is null and the other is not null. Code with null value (== empty): <div class="col-xs-6"> <iframe style="width:868px; height:550px;" id="FileReload" src="/Account/GetPDF?NUM=101"> <html> ...

Unexpected dependency mysteriously appeared in package.json during npm install

I'm in the process of developing a project using npm 7.24.0 and executing npm install --lockfile-version 2 --legacy-peer-deps After the project is built, it adds an additional line to package.json "dependencies": { "2": &quo ...

What is the proper error type to use in the useRouteError() function in react-router-dom?

In my React project, I am utilizing the useRouteError() hook provided by react-router-dom to handle any errors that may arise during routing. However, I'm uncertain about the correct type for the error object returned by this hook. Currently, I have ...

The Express.js application functions properly on a local environment, but encounters issues when deployed on Heroku

Currently, I am experiencing an issue with deploying a music visualizer that I created. It seems to work perfectly in all scenarios except when I click on a song to play from the search bar, where I keep encountering a '503 (Service Unavailable)' ...

What is the process of defining a group of particles in relation to a vector path using Three.js?

In my exploration of Three.js, I have been experimenting with particle clouds and their unique properties. Many examples I have come across utilize shape geometries to generate fields of particles or random parameters for their distribution. However, I a ...

Alert: React-Weather is causing an invalid element type in React

I am feeling overwhelmed. I have created a custom component called react-weather which has been installed using npm. Here is the code snippet for my self-written Weather.js component located in the src/components folder: import React, { Component } from & ...

Trouble with Ajax requests firing on document load in Firefox

When loading a JSP page in Firefox, I am invoking an AJAX function that calls a servlet. The servlet returns data in response. However, when I attempt to alert the data as shown in the code snippet below, I receive a null value. $.ajax({ url : 'S ...

Decoding JSON data into a C# object

After making an API call, I received the following result. What would be the most effective C# object structure to facilitate deserializing the JSON string into a C# object? An issue arises as the JSON objects represent the brand name rather than "data": ...

Guidelines on navigating a blank page using the Nuxt-js method

I have run into an issue in my Nuxt.js project where I need to open a link in a new target when a user clicks a button. Despite trying various solutions, I haven't been able to find a workaround within the Nuxt.js framework itself. <a :href=&qu ...

Extract the data from a JSON object

I am working with a Json string that looks like this: var Result= [{"CompanyID":32,"Roles":["Admin"]}] My goal is to extract the value of CompanyID from this data. One method I attempted was: var obj = JObject.Parse(Result); int Id=obj["CompanyID"]; ...

Transmitting Data via Socket.io: Post it or Fetch it!

I am struggling to send data via POST or GET in socket.io without receiving any data back. My goal is to send the data externally from the connection. Take a look at the code snippets below: Server-side code: app.js io.sockets.on('connection', ...