Launch HTML code in browser from Python

Lets say you have generated some html content for a web page dynamically and have it in memory variable in python.

In order to view and test this content, you would need a Python program that prints out the HTML code, which then would have to be copied and pasted to a HTML file, then from there, you can test it in a browser.

In Python, there is a way to launch such HTML code in a web browser so that you don’t have to go through the copy and paste method every time



Configuring maximum number of simultaneous open WebSockets (for IE)

Given I’ve got this JS application. All client side JS communicating using web sockets. One page may have multiple web sockets open as many as 10-15.

Firefox and Chrome handle this many open web sockets at once just fine. IE11 seemed to have a limitation of 6 open web sockets at once.

Once I open that 7th web socket, regardless of socket call to the third-party server, I got an error thrown by IE, which closes the socket and gives the general error “SecurityError” and expanding the __proto__ section it gives me . The error seems to be pretty generic.

At first it looks as if there may be a trusted zone type issue with IE, but even after adding the client site to trusted zone as well as the server providing the data, the error still persisted.


This site shows the max connections settings for IE. It’s a registry setting in Windows that controls the amount of web socket connections.

Interestingly enough, By default, windows doesn’t have that registry key, but there is still a limit. Therefore you have to add the Registry in order for this to work.

The MSDN Section mentions:

WebSocket Maximum Server Connections

Internet Explorer 10. When enabled, the FEATURE_WEBSOCKET_MAXCONNECTIONSPERSERVER feature sets the maximum number of concurrent WebSocket connections allowed to a single host. The minimum number that can be specified is 2 and the maximum value allowed is 128.

The default value for this setting is 6 in Internet Explorer and applications hosting the WebBrowser Control. To modify this feature by using the registry, add the name of your executable file to the following setting.

         Internet Explorer
                     contoso.exe = (DWORD) 0x00000006 (6)

This should fix the problem.



What is the difference between target=_new and target=_blank in HTML Code?

According to the HTML5 WIP Spec:

A valid browsing context name is any string with at least one character that does not start with a U+005F LOW LINE character. (Names starting with an underscore are reserved for special keywords.)

A valid browsing context name or keyword is any string that is either a valid browsing context name or that is an ASCII case-insensitive match for one of: _blank, _self, _parent, or _top.” –Source

That means that there is no such keyword as _new in HTML5, and not in HTML4 (and consequently XHTML) either.

That means, that there will be no consistent behavior whatsoever if you use this as a value for the target attribute.


How to make my browser trust my server certificate?

Hi Guys,

I was exploring the SSL thing, and wanted to know what are the steps involved in making my browser trust the server certificate that server is sending.

First of all you need to generate a keystore (This needs to be done on server side).

C:localhostCerts>keytool -genkey -alias server-alias -keyalg RSA -keypass welcome -storepass welcome -keystore localhost.jks
What is your first and last name?
[Unknown]: localhost
What is the name of your organizational unit?
[Unknown]: NSEL
What is the name of your organization?
[Unknown]: NSEL
What is the name of your City or Locality?
[Unknown]: NOIDA
What is the name of your State or Province?
[Unknown]: UP
What is the two-letter country code for this unit?
[Unknown]: IN
Is CN=localhost, OU=NSEL, O=NSEL, L=NOIDA, ST=UP, C=IN correct?
[no]: yes

Volume in drive C has no label.
Volume Serial Number is CE67-DC0D

Directory of C:localhostCerts

15-Apr-2012 01:10 PM .
15-Apr-2012 01:10 PM ..
15-Apr-2012 01:10 PM 1,338 localhost.jks
1 File(s) 1,338 bytes
2 Dir(s) 343,529,140,224 bytes free

The above command has generated a keystore (on the server side)

Now convert this into a server certificate (and send it to client side)

C:localhostCerts>keytool -export -alias server-alias -storepass welcome -file server.cer -keystore localhost.jks
Certificate stored in file

Volume in drive C has no label.
Volume Serial Number is CE67-DC0D

Directory of C:localhostCerts

15-Apr-2012 01:11 PM .
15-Apr-2012 01:11 PM ..
15-Apr-2012 01:10 PM 1,338 localhost.jks
15-Apr-2012 01:11 PM 563 server.cer
2 File(s) 1,901 bytes
2 Dir(s) 343,560,626,176 bytes free

Make the changes in server.xml

Make changes as given on in step 2.
(Take care of the file name)

Saved the server.xml on server and restart Tomcat, access to https://localhost:8443/

You’ll see a page as given below

As you see the google chrome doesn’t trusts the certificate that was provided by the server.

Check untrusted certificate on client side

If you open server.cer (provided by the server) by double clicking, you can see the message as given below

This CA Root certificate is not trusted. To enable trust, install this certificate in the Trusted Root Certification Authorities Store

How to add this certificate to Trusted Root Certification Authorities on Google Chrome??

  1. Tools -> Settings
  2. Click on Show advanced settings at the bottom of the page
  3. Click on Manage Certificates
  4. Click on Trusted Root Certification Authorities tab
  5. Click on import
  6. Select server.cer from your machine
  7. Next, Next, and Finish
  8. You should get a import successful message

Again open the server.cer, and now you should see the certificate as follows.

if you open https://localhost:8443/ in IE or google chrome you will NOT see the warning and in the address bar, you’ll notice the lock.

Making the input file box readonly in IE

Is it possible to prevent a user from typing in a file input text box in IE? The reason I ask is that if a user enters text that does not look like a file system path (eg. doesn’t start with something like c:…) then when the user clicks the submit button nothing will happen.

I would either like to not allow the user to type in the box


onContextMenu="return false;">

In IE 7.0 and IE8.0 this fix is not required. As it has already been made readonly by Microsoft. This fix is specifically required for IE 6.0

How to make hover effects work in Internet Explorer

Thanks to for the post. 🙂

I spent about an hour this morning trying to figure out how in the world to get IE7 to apply my :hover styling to a non-anchor () element. Amazingly enough, numerous searches on Google turned up absolutely nothing. I found one forum post that looked promising, but it was one of those depressing forum posts that states the exact same problem you’re having, but doesn’t have any replies.

What made things more frustrating was that there are blog posts galore touting IE7’s addition of support for :hover on all elements, yet no matter what I tried I couldn’t get it to work!

Eventually, I recalled reading something on the IEBlog about how a web page’s DOCTYPE would dictate the CSS support in IE7. The gist of it is, if you want support for :hover on all elements and not just the tag, make sure you’re using a strict DOCTYPE so IE7 doesn’t kick in to quirks mode.

Whereas the following HTML resulted in my hover effects working in Firefox but not IE7


table { background-color: #DDD; }
tr:hover { background-color: #000; color: #FFF; }
p { background-color: #EEE; }
p:hover { background-color: #CCC; }

This is just one of those paragraph things.

This here is a table row.
This is a table row too.

…simply adding the HTML 4.01 Strict DOCTYPE to the top of the HTML document made IE7 obey my :hover rules as well:



table { background-color: #DDD; }
tr:hover { background-color: #000; color: #FFF; }
p { background-color: #EEE; }
p:hover { background-color: #CCC; }

This is just one of those paragraph things.

This here is a table row.
This is a table row too.

Internet Explorer 7 and later, in standards-compliant mode (strict !DOCTYPE), can apply the :hover pseudo-class to any element, not merely links.

Not enough arguments [nsIDOMWindowInternal.alert]

function callfn()

This will give error somewhat similar to

uncaught exception: [Exception… “Not enough arguments [nsIDOMWindowInternal.alert]” nsresult: “0x80570001 (NS_ERROR_XPC_NOT_ENOUGH_ARGS)” location: “JS frame :: :: :: line 810” data: no]

Please note that this error appears specifically in Firefox. (Not sure about other browsers).

Source :