0

I have written a script to open a page in new tab on click of a command button. Unfortunately I get the following error:

window.open is not a function()

I have not created any variable named "Open" which may have over written the open() function.

My script is like this

<script>  
function newpagePDF() {
          alert('Hi11');
          var stringcase = '{!caseid }';
          var newpage = window.Open('/apex/ZEB_RMA_Pdf?CaseId='+stringcase );
    }

</script>

My command buton is :

<apex:commandButton value="Generate Pdf"   onclick="newpagePDF();"/>
| improve this question | | | | |
1

Try following statements:

window.open(('/apex/ZEB_RMA_Pdf?CaseId='+stringcase), window.name, "height=600,width=700");

or

window.open(('/apex/ZEB_RMA_Pdf?CaseId='+stringcase), '_blank', "height=600,width=700");
| improve this answer | | | | |
  • Sorry ..but its not working – Ankita Singh Jun 23 '15 at 6:53
  • Are you getting exception or the tab is opening in new tab? Try to copy and paste the given code and make sure stringcase is defined. It should work. @AnkitaSingh You have typo mistake in function. – Ashwani Jun 23 '15 at 6:56
  • I have defined string case.I am getting a new error now : GET na10.salesforce.com/17181/logo180.png 404 (Not Found) – Ankita Singh Jun 23 '15 at 7:00
  • This error has no relation with the JavaScript you wrote. I may ignore it @AnkitaSingh. – Ashwani Jun 23 '15 at 7:02
  • 1
    Try it window.open(('/apex/ZEB_RMA_Pdf?CaseId='+stringcase), '_blank', "height=600,width=700"); @AnkitaSingh – Ashwani Jun 23 '15 at 7:06
2

The reason actually is pretty simple: Unlike apex, javascript is case-sensitive. So instead of using window.Open, use window.open will resolve your issue

| improve this answer | | | | |
  • i am already using window.open in my code..still it doesnot work – Ankita Singh Jun 23 '15 at 6:54
  • @AnkitaSingh what is the error then? Shouldn't be Open is not a function though – Lance Shi Jun 23 '15 at 6:56
  • Error is : GET na10.salesforce.com/17181/logo180.png 404 (Not Found) – Ankita Singh Jun 23 '15 at 6:59
  • @AnkitaSingh , this is the error in your visualforce page. Though you have defined your string and the caseId is correct, when it passes to VF page and try to get the resource, it failed to get the logo. I guess this is a very separate question. If you still need guidance on that, I would suggest you paste your VF code in. – Lance Shi Jun 23 '15 at 7:03
  • Kindly refer to link for code – Ankita Singh Jun 23 '15 at 7:22
0

Change the window.open as below,

var newpage = window.Open('/apex/ZEB_RMA_Pdf?CaseId='+stringcase ,'_blank');

_blank - opens page in new tab

Try this.It will work..

| improve this answer | | | | |
  • Its still not working – Ankita Singh Jun 23 '15 at 6:34
  • whether it is opening in same page? Do you have code that page*(ZEB_RMA_Pdf)? – wAitIng dOg Jun 23 '15 at 6:35
  • it is opening in same page. i didnt get your second question..sorry? – Ankita Singh Jun 23 '15 at 6:37
  • I tried opening a different page..that also does not work..that also gives me the same error – Ankita Singh Jun 23 '15 at 6:38
  • Sorry my question had typo.Do you have a page like ZEB_RMA_Pdf?.Also change that Open to open in script – wAitIng dOg Jun 23 '15 at 6:39
-1

you can try this code on the vf page

<apex:commandButton value="Generate Pdf" action="{!----}" reRender="" onclick="window.open('/apex/ZEB_RMA_Pdf?id={!Case.Id}');" />

in the place of action u write the mehthod name whom u want to open in the new page

| improve this answer | | | | |
  • <apex:commandButton value="Generate Pdf" action="{!----}" reRender="" onclick="window.open('/apex/ZEB_RMA_Pdf?id={!Case.Id}');" /> – Piyush Kumar Jun 23 '15 at 7:22
-1

you can try this code on the vf page :

<apex:commandButton value="Generate Pdf" 
                        action="{!----}" 
                        reRender="" 
                        onclick="window.open('/apex/ZEB_RMA_Pdf?id={!Case.Id}');"     
    />
| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.