Working on Java script.
Hi guys, Here i did some Java script stuff , i am sharing with you guys,
Hi Guys Here we have a scenario, Create a VF page with two buttons. Those are
"Open in PDF" and "Open in Word" ,
When we click on any button the vf page should open in Pdf/Word format Based on Button click.
Here we go..
<apex:page controller="some class" showHeader="false" renderAs="{!ispdf}" contentType="{!isword}">
.........
......
.........
<center><br/>
<apex:form rendered="{!isvf}" id="frm1">
<apex:commandButton reRender="frm1" action="{!donothing}" value="Open in PDF" onclick="window.open('/apex/vf page name?id={!$CurrentPage.parameters.id}&type=pdf','_blank')"/>
<apex:commandButton reRender="frm1" action="{!donothing}" value="Open in Word" onclick="window.open('/apex/vf page name?id={!$CurrentPage.parameters.id}&type=word','_blank')"/>
</apex:form>
</center>
How to get user id in Java script Buttons.
alert('{!$user.Id}');
How to get profile id in Java script Buttons.
alert('{!$Profile.Id}');
How to open a Vf page in a new Window using java script button.
{!REQUIRESCRIPT("/soap/ajax/8.0/connection.js")}
{!REQUIRESCRIPT("/soap/ajax/15.0/apex.js")}
var url="/apex/vf page name ?id={!Opportunity.Id}";
if('{!$Profile.Id}'=='some id' ||'{!$Profile.Id}'=='some id') // it should work for two profiles only
{
newWin=window.open(url, 'Popup','height=800,width=1100,left=100,top=100,Right=100');
}
How to write code for save & close operation done in one button click.
<apex:commandButton action="{!save}" value="Save" rerender="AJAXTest" status="AJAXStatus"/>
<apex:actionStatus startText="(Saving...)" stopText="" onStop="window.top.close();" ID="AJAXStatus"/>
=========================================
Thank you for this useful information
ReplyDeletephp development