Added some type checking and fixed Iframe bug for external pages