Print Web Page without header and footer (by code) [duplicate] - javascript

This question already has answers here:
Disabling browser print options (headers, footers, margins) from page?
(9 answers)
Closed 8 years ago.
I want to print a web page from IE without the header and footer that IE generates by default (in the footer there is the URL). Important this should be done by JavaScript or VBScript code and NOT the print settings for your web browser
thank you in advance, best regards.

If you're talking about the header and footer generated by the browser (i.e. page numbers, URL, etc.), then you cannot do it. These elements are generated outside the scope of the web page - and you have no control over them. They are part of user's configuration of their system and can only be manipulated by the user.

Related

Remove certain scripts invoked by an iframe [duplicate]

This question already has answers here:
Cannot modify content of iframe, what is wrong?
(3 answers)
Closed 2 years ago.
I would like to add an iframe to my webpage. The problem is that there are several malicious scripts and ads in the iframe. Is there a way to block certain scripts (like Adblock does) using HTML or JavaScript?
tl;dr: No
The sandbox attribute on the iframe element lets you apply some limits to what scripts can do (e.g. you can block popups) but it can't be used to block specific scripts.
All the techniques for blocking specific scripts have to be applied by the owned of the actual page the script is embedded in. If you trust the owner of the page you are putting in a frame, then they can do what they like (except interact with your page thanks to the same origin policy).
There is a proposal to allow a CSP to be applied to a frame from the parent document, but it doesn't seem to have been updated in half a decade so I'm assuming the idea has died on the vine.

How do I check and inform user had javascript enabled in browser [duplicate]

This question already has answers here:
How to detect if JavaScript is disabled?
(39 answers)
Closed 5 years ago.
My desktop application creates a html report at the end showing results and opens it in users default webbrowser. The report is in html5 and utilises a frameset, clicking items on the left hand frame changes the display on the right handside.
But one for one user it didn't work because they had NoScript add on installed which I think by default disables Javascript.
What is the accepted way to inform users they need Javascript enabled, can the report itself proactively identify whether Javascript has been disabled (for the report).
You can use <noscript> tag which will be shown only if Javascript disabled:
<noscript> App can't run without JavaScript</noscript>

Is there any way to define back/forward button effects on a web page? [duplicate]

This question already has answers here:
Javascript : Change the function of the browser's back button
(5 answers)
Closed 8 years ago.
I have a page where the content is delivered mostly though javascript. Hitting the back button would basically exit the page to wherever the user came from instead of showing the previous content. Is there a way to take manual control over what the back/forwards buttons do on a web page?
This is a classic AJAX problem - each page is loaded asynchronously with no new GET from the browser, thus no history.
Look into History API of HTML5 to programatically push page state into the browser history. Other than that you are out of luck.

HTML <a> hyperlink target inPrivate / incognito window [duplicate]

This question already has answers here:
How can we open a link in private browsing mode
(2 answers)
Closed 8 years ago.
Is there a way, via Javascript or other code, to open a url in a private/incognito window from an HTML page? Ideally cross-browser or at the very least IE and Firefox.
The anticipated behaviour would be along the lines of
Link
The simplified reason for this is because admins want to be able to log in as users to preview various pages, but without logging themselves out. Whilst there are various other ways around this issue, this would be the simplest (assuming it is possible).
We can't force the visitor to view the page in an incognito/private window. Browsers provide no API that would make that possible outside of an extension.

The difference between the code in background-script and content-script [duplicate]

This question already has an answer here:
Difference between background script and content script in chrome extension
(1 answer)
Closed 8 years ago.
I want to create an extension that reads all the colors of a site and change all the colors accordingly, if you click on the button.
Where should I write this code?
In a content script or in a background script?
What is actually the difference between the two?
Read the well-written Overview at the documentation. This should answer a lot of your questions.
In short, content scripts execute in an isolated context of a webpage, having access to its DOM, but have very limited Chrome API access.
A background script is usually used for central handling of tasks, while content scripts act as intermediaries between it and pages you want to interact with.
As for your situation:
You need to have a background script to listen to the button click event.
You need to have a content script to interact with a page.
So, you need both, and the background script can message the content script to do its magic.

Categories