PDA

View Full Version : Problem using javascript in Switch Content Script



sowjanya
11-02-2007, 07:50 PM
1) Script Title:
Switch Content Script

2) Script URL (on DD):
http://www.dynamicdrive.com/dynamicindex17/switchcontent.htm

3) Describe problem:
I have some problem using javascript:openwindow() function in the Switch Content Script. Its always giving me an error saying Object Expected.
Here is the code I have used.


<table border="0" width="100%" cellspacing="0" cellpadding="0" align="center">

<tr><td>&nbsp;</td></tr>
<tr>
<td valign="top">
<table width="100%" cellpadding="0" cellspacing="0" align="center" >
<tr class="tdbgdark" height="26" VALIGN="middle"><td>

<h5 id="bobcontent1-title" >Notes: (<bean:write name="projectPage" property="notesSize" scope="request"/>)</h5>
</td>
<td align="right"><b>
<input type="button" name="ADD" value="ADD" id="ADD" class="btnbutton" onClick= "javascript:openWindow('Notes_AddLink.do?piNbr=<%=PI %>','Notes',700,600)">&nbsp;&nbsp;<input type="button" name="SEARCH" value="SEARCH" class="btnbutton" id="SEARCH"></b></td>
</tr>
<tr> <td colspan="2">
<div id="bobcontent1" class="switchgroup1">
&nbsp;&nbsp;&nbsp;<B>ABEA </B><tiles:insert page="/Notes_View.do" flush="true"/>
</div>
</td></tr></table>
</td>
</tr>


</table>



Here every thing is working fine but when I attempt to open the new window by clicking on the ADD button its giving me the error as Object Expected and if I remove the button nothing is wrong. Please help me out in placing the button in my code i.e in resolving this issue.

Thank you.

jscheuer1
11-02-2007, 09:58 PM
Neither:

javascript:openwindow()

nor (as you have it in the actual code):

javascript:openWindow()

are native javascript methods. So, if the function that it refers to is not available to the page (a function is an object) - "Object Expected". Another potential problem is this (red):


'Notes_AddLink.do?piNbr=<%=PI %>'

This looks like asp server side code to me. In any case, it had better be some sort of server side code, if it isn't, the > part makes the browser think you are closing the input tag. Even if it is server side code, if the page it is on isn't being processed server side - lacks the proper, probably .asp extension for its filename, or the server it is on isn't enabled for this type of server side code, or you are running it locally - any of that, and it will make the browser think that the input tag has been prematurely closed. If that's happening, it could also give the "Object Expected" error, as it looks like you are running a function, but there are mal-formed parameters. Parameters are also objects in javascript.

So, you tell me, which is it?

Or:

Please post a link to the page on your site that contains the problematic code so we can check it out.

sowjanya
11-05-2007, 03:27 PM
Hi,
Thank you for your reply. I am using struts framework here and .do is the extension used. Over here I had written a js function openWindow() to open the new window through java script, I have included that In the layout jsp file. May be its not included, and I tried including the script file in this page and the error is gone.

Thanks a bunch for your help.


Neither:

javascript:openwindow()

nor (as you have it in the actual code):

javascript:openWindow()

are native javascript methods. So, if the function that it refers to is not available to the page (a function is an object) - "Object Expected". Another potential problem is this (red):


'Notes_AddLink.do?piNbr=<%=PI %>'

This looks like asp server side code to me. In any case, it had better be some sort of server side code, if it isn't, the > part makes the browser think you are closing the input tag. Even if it is server side code, if the page it is on isn't being processed server side - lacks the proper, probably .asp extension for its filename, or the server it is on isn't enabled for this type of server side code, or you are running it locally - any of that, and it will make the browser think that the input tag has been prematurely closed. If that's happening, it could also give the "Object Expected" error, as it looks like you are running a function, but there are mal-formed parameters. Parameters are also objects in javascript.

So, you tell me, which is it?

Or:

Please post a link to the page on your site that contains the problematic code so we can check it out.