简体   繁体   中英

Iframe Http error handling

I am using iframe to show my database result.But for the veryfirst time since I am not hitting the database so in that case iframe is showing datatable.jsp page is not available (dataTable.jsp is the page for showing database table result).I searched in google and i found something called onError and onLoad methods for iframe.If anybody can show me a small example of how to show a different jsp if for the first time required src is not avaialable it would be a great help for me.

Thanks in advance

<iframe id="dataframe"  src="dataTable.jsp" name="dataTable"  width="720px" height="620px"  align="middle" frameborder="0">

</iframe>

Well, with javascript, this could be a way:

HTML:

<iframe id="dataframe" name="dataTable"  width="720px" height="620px"  align="middle" frameborder="0">
</iframe>

(removed the src attribute)

Then, when you want to load the datatable with your jsp content

JS:

document.getElementById("dataframe").src = 'dataTable.jsp';

Hope this helps, Cheers

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM