Thursday, June 26, 2008

The script tag requires a closing tag in XHTML

Platform: ASP.NET

If you don't close the script tag in head or body of an ASPX file, then you will get a strange error: __doPostBack is not defined

Problem: Any script (and style) tags need a closing tag. Don't close these tag like:

<type="text/javascript" src="somefile.js" />

Solution: The script tag either in the head or the body of an XHTML file has to have a closing tag. Correct this javascript error by doing this:

<type="text/javascript" src="somefile.js"></script>

Possible reason: This has to do with the content of the script tag being defined as #PCDATA in its DTD.

Friday, June 13, 2008

Ways of accessing a frame in a frameset using javascript

< frameset rows="100px, *">
   < src="/header/index.html" name="headerFrame">
   < src="http://www.someothersite" name="otherFrame">
< /frameset >

let's say that in the www.someothersite page, you would want to access itself, i.e. the page elements, you have three options:

a) parent.otherFrame: The issue here is that if your page is being hosted in another site, i.e. your page is framed by others, then they may, at one point, decide to name the frame differently. However if this is your own site, then there shouldn't be a problem.

b) parent.frames[1]: The issue here is that your expecting that the frame index is always at 1. Again, if you have no control over the order of the frames, then you will have an issue.

c) self: This is the best option as your page will work regardless of the hosting page changes.

That's it.