Microsoft Edge not opening my HTML Page - javascript

In my current web project i create reports based on data entered by User which opens in new tab. format of report is also decided by user whether in pdf or html. This functionality is working fine in all browsers including IE7/8/9/10. But recently when i am opening the same in Microsoft Edge, rather then opening report HTML in new tab it starts downloading the HTML file.
Other redirection links of menu page are working fine in Microsoft Edge. Problem is only in opening those reports in new tab.
Can you guys please help me out??

As #Diptendu pointed out in the comment, You will need to specify a 'Content-type' of 'text/html' so that the browser knows that the content is strictly HTML and should render it accordingly.

Browser tries to download a file instead of rendering when it faces some content type which it cannot handle. In your case browser is interpreting an invalid content type and hence trying to downloading it instead of rendering on a new tab. By specifying 'Content-type' as text/html you can tell the browser explicitly that the content is HTML and should be handled like HTML content.

Related

Firefox not downloading correct file to machine

I have a react application that I built that uses redux, react router v4 and d3 for visualization of data.
My app contains a force directed graph, a table and a histogram. Each one of these views contains clickable nodes, table cell and bars that when clicked, the file should download to user's machine. I recently updated firefox to the latest version 62.0.2 and the download no longer functions as expected, however it still works fine in Chrome.
The files sit on the same domain as the application and I've coded the download to function as so:
let newlink = document.createElement('a');
newlink.setAttribute('download',
'https://www.example.com/docs/xml/file1.xml');
newlink.setAttribute('href', 'https://www.example.com/docs/xml/file1.xml');
newlink.setAttribute('target', '_blank');
document.body.appendChild(newlink);
newlink.click();
What firefox is doing is downloading the index.html file at my app root rather than what is in the url variable (ex. https://www.example.com/docs/xml/file1.xml). The dialog shows that it is in fact trying to save the file with the correct name (Firefox has automatically replaced '/' with underscores to save the file. The domain is correct, but the location does not contain the full URL to the file. Is something happening with the full URL being chopped off somehow?
The type on the dialog box is HTML (which is incorrect, all my files are either xml or txt) and if user selects save or open, it saves index.html or opens up a blank/black webpage. I'm going crazy trying to figure out what is happening here. Please help!
What ended up fixing this in Firefox was unregistering the service worker from the application's domain by navigating to about:serviceworkers (in firefox). I then commented out the register service worker function in my UI code because I'm not using them for this application anyway. For whatever reason the service worker was intercepting the file download and causing the browser to download the index.html file rather than the text file it was supposed to. Once I did these two things, the file was downloaded correctly. If anyone would know why that would be, I'd love a comment.

URL Parameters are not processed when opening in MS Edge

Okay, here's a weird issue for you guy sand gals.
I'm using a window.open tag in JS to open a .cfm file that will open in Excel (Report), however, the appended URL variable appears to change. It seems that the ? gets changed to an _ and thus the browser thinks its a text file and not a web page. Any Ideas??
window.open("amal_reports/rpt_change_indicator_notes.cfm?batch="+selBatch);
The URL should be
http://example.com/amal_reports/rpt_change_indicator_notes.cfm?batch=1160 but when the browser asks what do with the file it says
rpt_change_indicator_notes_cfm_batch=1160 and wants to open a text
file.
If I call the report directly in the URL without the form or JS stuff the same thing happens, conversely, if I remove the URl variable (?batch=1160) the report opens in Excel as expected but no data is populated because the batch number is missing.
So, to summarize, the browser is changing my .cfm link from js or directly in the browser to _cfm and thus it won't open in Excel as expected.
Okay, developer error! It looks as though checking the developers tool (F12) based upon theGleep suggestion, I found that my page was missing or couldn't find a variable. Once that was corrected the report open as expected.

How to set breakpoint in Chrome for when flash video is loaded?

In the Chrome debugger's 'Network' tab, the 'Other' sub-tab shows a .flv Flash file being played. I'm trying to figure out exactly where/how that .flv URL is being generated, but I've looked through the JS for the site and can't figure out where it comes from.
Is there a way to set a breakpoint for when that .flv file starts getting streamed/played so that I can figure out how it's URL is being put constructed?
The request headers for the flv file in the Chrome debugger show X-Requested-With:ShockwaveFlash/24.0.0.194. So the request comes from Flash rather than from a JS file I think.
Or any other ways to figure it out?
Either the embedded SWF (Flash) app has specific code to construct the url (then method is unknowable) or else the app is reading the url from somewhere like a JSON or XML text file.
It could also construct by reading the text within an HTML / JS file. Third possibility is that PHP is involved in generating a link. So check the Network tab for such things (xml, json,php files which you open in a "new tab" to read).
Was there no flv found when you word-search the source of html or JS?... If all else fails then provide a testable link.
PS: To answer your Question : There's no loader breakpoints / load pausing in Chrome.
On Network tab you have multiple columns. One of them it's called Initiator. If' is missing, right click on any column and a dropdown with all columns available will appear. Check Initiator column.
That column should tell you what you need to find out.

Can I create a new web page from the HTML in a div using javascript?

I have a web page that allows a user to choose some options for a widget and then dynamically generates example HTML based on those options. The HTML is put in a div on the page so that the user can see how it looks and copy/paste it to their own site, if they so desire.
I would like to add a "view this example page" link, which opens in a new window and has the example HTML from the div, so that the example can instantly be seen in action.
Is there a way to do this with javascript/jquery?
You can actually use the window.open method, saving a reference to the opened window, and then writing to it.
https://developer.mozilla.org/en-US/docs/Web/API/Window/open
var exampleWin = window.open("", "example");
var docMarkup = "<!doctype html><html><head><title>test</title></head>" +
"<body><p>Hello, world.</p></body></html>";
exampleWin.document.write(docMarkup);
// later you can also do exampleWin.close() if you wish
Try pasting the above code in your browser's developer tools console.
The usual way to accomplish the end goal works a bit differently. You have a web server listening for GET requests at /code (or similar) and it constructs and responds with the appropriate HTML based on the query string. So you can request /code?color=blue, for example.
Constructing documents is what web servers are designed to do. This approach allows you to leverage caching policies, integrate with a wider variety of user authentication and authorization systems, etc.
To display the source code to the user, simply fetch() the appropriate URL and put the contents in a <code> tag. To display the rendered widget, use an <iframe> whose src is the same URL.
If you really want it to be a new window, open() the URL instead of using an iframe. But beware of popup blockers.

Winnovative HTML to PDF Converter - Not saving a dynamic javascript page

I have tried looking for a solution to this problem on the site, but can't appear to find one. I have limited knowledge about this particular subject, so please excuse my ignorance!
Our website converts HTML to PDF using the Winnovative HTML to PDF converter.
The pages that need to be converted are using KnockoutJS and therefore the HTML code is not in the page source when the page is originally loaded.
I have tried setting a 30 second page delay, but it seems like the converter won't even save our home page, e.g. www.zapkam.com, let alone the pages that I actually need to save, e.g. http://www.zapkam.com/print.htm#/Orders/ZK1019467/Order/
This had previously been working fine on version 11.6.0.0 on a Windows 2008 Server, but since transferring to version 12.5.0.0 on a Windows 2012 Server, it is no longer working.
The fact that it was working before seems to point towards it potentially being a permissions issue as the server is not configured, but I would be very grateful for any insight!!
It will done using Javascript with Canvas,
As I had written code in your Print.html Page..
After successful HTML Rendered we need to call my button "print PDF" find in demo application..
Look into my demo Index page , It will create PDF and write to the client browser..
please check attached application..
www.maplayout.com/zampak.zip
Thanks,
Abhishek

Categories