How to hide html source code? Even when viewing source? - javascript

I found this website https://samy.pl/ and even with my HTML knowledge I can't find the source of his site?
If you type "view-source:" before the website it should bring up the source but it doesn't?
He blocked most or all ways to inspect his source.
How is this possible?

You can actually see the sourcecode using Internet Explorer, or Safari with IE 11 set as useragent.
I'm not certain how he does it, but it is some kind of JavaScript that checks some flag in Chrome that tells him whether or not the inspector is open, and if true he removes the body and updates page so everything disappears.
Using IE and inspecting the source should give you the answer :)

Related

Chrome PDF viewer malfunctioning when extension in started

I have a chrome extension which allows to write on screen in chrome tabs. The default behaviour looks like :
It works be simply inserting a canvas tag in the DOM and doing all the stuff in it. It works well in all sites. However, chrome PDF viewer behaves strangely when I use it :
Before -
After -
I don't think there is any issue with the extension because it works on all other sites. I think there is an issue with chrome PDF viewer itself.
I can attach the code here if asked in comments.
Ok, so I tried to replace all innerHTML += <value>; by insertAdjacentHTML("afterbegin",<value>); And now it's working fine.
It's because your canvas must be on top to ensure it will works on every website.
The z-index propery is not enough for that.
Hope that helped !

Website not working in Firefox/Chrome, but does in IE

There is a website that I must use at work quite a bit and the only browser it works on is Internet Explorer.
I'm presuming this is because the code is outdated/incorrect and includes javascript that only IE is able to read.
This is a problem, because I want to use Firefox or Chrome, they are much better browsers.
I believe the issue is Firefox/Chrome (hereinafter referred to as foam) not being able to recognize the following "onclick" command lines. When I press these buttons, the web page does not change as it should.
<button class="MenuButton" title="Create ICL" value="ADDICL" onclick="PageJump('ICLMain.asp?From=ICLHome')">Create ICL
So.... since this is not my website, I cannot re-write all of this code to fix it. It is a corporate owned underwriter website for creating a certain document.
There must be some sort of extension that enables Firefox/Chrome to read Javascript codes like Internet Explorer so that I can use Firefox/Chrome and still use this website.
Try to use chrome extension ie tab, https://chrome.google.com/webstore/detail/ie-tab/hehijbfgiekmjfkfjpbkbammjbdenadd?hl=es. This extension emulate The ie Explorer.
I'm also facing the same problem(Javascript broke). The solution I found is to just add https:// before the link and reload the page and everything will work fine again.

Chrome User Agent not displaying script - CSS fix?

I installed a WP theme recently and am having trouble getting a Facebook conversion box to display when I visit my site through Chrome. This problem doesn't exist on Firefox.
The response I get on Chrome is no visible pop-up box, but upon inspecting the element, I do see the code for the box in my header.php with a line from the Chrome User Agent saying:
script {
display: none;
Is there a CSS solution to override the User Agent and get the script to display? Again, I have no problems with the theme on Firefox. Here's a link to my site.
Thanks in advance!
I think I found the source of your problem. It's a browser extension.
Your conversion box appears on my personal laptop. However, it doesn't on my work laptop. That lead me to believe that it was a conflict with the script & a browser extension. So I opened your site in an incognito window. Voila! it worked. The next step was figuring out which extension was blocking it. For me, it is LastPass (my work requires the use of LastPass).
If you have LastPass enabled as an extension, disable it. Then test again.
It'd also be a good idea to get these console errors figured out:
Uncaught SyntaxError: Unexpected token ; (index):476
carouFredSel: No element found for "#foo1". jquery.carouFredSel-6.2.1.js?ver=3.8.3:4232
Uncaught ReferenceError: paginateVal is not defined cgview.js?ver=3.8.3:28
Solutions
Unfortunately, there isn't much you can do about people's individual extensions. If this is an absolutely critical feature for you, I'd look at finding a different implementation of it. One that does not conflict with common extensions (that's the easy option).
The other option (harder) is to look into the code of the plugin/script that you're using for the conversion box and identify the conflict.
Last option (hardest) is to look at LastPass extension source code and identify the bug that is preventing other scripts from running. I've had issues with LastPass interfering with javascript in the past.

How to view javascript generated html for Internet Explorer?

I am looking for a way in IE to view the html source generated from jQuery code.
Ex.
HTML:
<div id="myDiv"></div>
jquery:
var wrapper = $("myDiv");
var generated = $("<div>Hello world</div>");
wrapper.append(generated);
I'd like to be able to examine and hopefully tweak the source generated by appending the generated element, not in Chrome or Firefox, but in IE 8 (where the problem is). I think that IE Developer Tools only shows the downloaded source, not what is generated.
Thanks.
Try going to the HTML tab in IE developer tools and press the refresh icon (next to the save icon), it will show the latest DOM.
Example:
Go to script tab and do:
document.body.appendChild( document.createElement("div") );
Then go to the HTML tab and hit the refresh icon and open the body tag, it should show the appended div now.
I recommend Firebug Lite - http://getfirebug.com/firebuglite (it's Firebug for IE, sort of)
You should get Firebug Lite. You can check the code that jQuery does and much more.
Anyway, I recommend that you put Google Chrome Frame compatibility on your site, it will eliminate plenty of problems with your site (with the people that have Google Chrome Frame installed).

How to get resultant HTML after executing all scripts?

How to get effective HTML after executing all scripts?
Actually scripts are adding and modifying control and css in the page. I would like to see html of resultant display as a static page. Is there any way to get this?
Edit: Suppose if background image is added using javascript, How can i see in Html OR css?
Please try to get this before giving answer.
One way would be to use Firefox with the Firebug extension.
Firebug is an extension for web developers. Among other things, it offers an "HTML panel":
The HTML panel displays the generated
HTML/XML of the currently opened page.
It differs from the normal source code
view, because it also displays all
manipulations on the DOM tree.
[...]
A similar solution for MS Internet Explorer would be the Internet Explorer Developer Toolbar.
Note that both solution are browser-specific. There is no way to get the resultant HTML independent of the browser used, because this HTML only exists in the working memory of the browser (so you cannot, say, sniff it on the network).
Use the firebug plugin for firefox, with it you can 'view generated source'.
This is a javascript approach. Unfortunately, it doesn't work perfect. For example, it doesn't include the contents of textarea's.
document.documentElement.innerHTML
Another way is selecting everyting (Ctrl + A) and choose 'View selection source' from a context menu.
The Web Developer Toolbar addon for Firefox has a 'View Generated Source' button that let's you do that. It's under the 'View Source' Menu of the toolbar.
It presents manipulated document as a static source, like what the "View Source" option does, but with modification by the Javascript.

Categories

Resources