Results 1 to 3 of 3

Thread: Problem using javascript in Switch Content Script

  1. #1
    Join Date
    Sep 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Problem using javascript in Switch Content Script

    1) Script Title:
    Switch Content Script

    2) Script URL (on DD):
    http://www.dynamicdrive.com/dynamici...tchcontent.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.
    Code:
    <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.
    Last edited by jscheuer1; 11-02-2007 at 09:43 PM. Reason: disable smilies

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    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):

    Code:
    '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.
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Sep 2007
    Posts
    8
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Got the problem solved--thank you

    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.

    Quote Originally Posted by jscheuer1 View Post
    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):

    Code:
    '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.
    Last edited by jscheuer1; 11-05-2007 at 03:41 PM. Reason: disable smilies

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •