You need to sign in to do that
Don't have an account?
Rose Farnham
How to add JavaScript via your browser's developer console?
I am new to Visualforce and I am doing the Trailhead: Visualforce Basics Module - Use Standard Controllers. The instructions state:
To preview your page in the context of Lightning Experience, open your browser’s developer console and enter:
$A.get("e.force:navigateToURL").setParams(
{"url": "/apex/pageName"}).fire();
I am not sure where to enter this. When I enter it in the Visualforce page the text just show up on the Visualforce page preview. I must be missing something. Any help will be greatly appreciated.
To preview your page in the context of Lightning Experience, open your browser’s developer console and enter:
$A.get("e.force:navigateToURL").setParams(
{"url": "/apex/pageName"}).fire();
I am not sure where to enter this. When I enter it in the Visualforce page the text just show up on the Visualforce page preview. I must be missing something. Any help will be greatly appreciated.
I am using Chrome DevTools as browser's console.
To open the dedicated Console panel, either:
Press Ctrl+Shift+J (Windows / Linux) or Cmd+Opt+J (Mac).
If DevTools is already open, press the Console button.
When you open the Console panel, the Console drawer collapses automatically.
https://developers.google.com/web/tools/chrome-devtools/console/
https://trailhead.salesforce.com/fr/modules/visualforce_fundamentals/units/visualforce_creating_pages
The rendered page opens in a new window. Note that this page preview shows your page without Salesforce styling.
To see your page in the context of Lightning Experience, open your Chrome browser’s developer console and enter:
$A.get("e.force:navigateToURL").setParams( {"url": "/apex/HelloWorld"}).fire();
or
$A.get("e.force:navigateToURL").setParams( {"url": "/apex/HelloMobile"}).fire();
Regards
Alain
All Answers
I am using Chrome DevTools as browser's console.
To open the dedicated Console panel, either:
Press Ctrl+Shift+J (Windows / Linux) or Cmd+Opt+J (Mac).
If DevTools is already open, press the Console button.
When you open the Console panel, the Console drawer collapses automatically.
https://developers.google.com/web/tools/chrome-devtools/console/
https://trailhead.salesforce.com/fr/modules/visualforce_fundamentals/units/visualforce_creating_pages
The rendered page opens in a new window. Note that this page preview shows your page without Salesforce styling.
To see your page in the context of Lightning Experience, open your Chrome browser’s developer console and enter:
$A.get("e.force:navigateToURL").setParams( {"url": "/apex/HelloWorld"}).fire();
or
$A.get("e.force:navigateToURL").setParams( {"url": "/apex/HelloMobile"}).fire();
Regards
Alain
You have to "Switch to Lightning Experience" first.
Regards
Thanks you so much for your response to my questions. I am currently using Firefox and with your response I am able to do it with Firefox. I was unaware of the developer tools within the browsers itself.
Yes, I was in Lightning Experience.
Have a great day!
Thanks Rose for having the good practice of closing the questions when they are solved.
Have a great day too!
I'm getting this too. Can someone help with this?
Step 2 - Ctrl + Shift + J (From your keyboard)
Step 3 - Paste
$A.get("e.force:navigateToURL").setParams(
{"url": "/apex/pageName"}).fire();
Note - 1. Do not forget to change VF page name.
2. Do not paste your code on your VF page preview tab otherwise it will throw error "$A is not defined at<anonymous> 1:1".
when I add the above in firefox console I get an error "cant use '$A.get("e.force:navigateToURL").setParams('." and "Available Options Too many options". anyone an idea how to solve that?
at <anonymous>:1:1
Please check my reply where is I also tell the Note that why you get this error.
Thank Judy S. I've had the very same error of "$A is not defined" on the preview page when I ran the "$A" code there. Instead, run the code on your Trailhead Playground home page where, I think, the needed lightening force platform has been loaded correctly.
So you need to follow the steps given below to resolve the issue.
1. login on salesforce using your username and password.(if not already logged in or playground is not opened) Url:(https://login.salesforce.com/), use your trailhead credentails or dev org credential.
2. Above will open your dev org or palyground. (if it is not ligthtning then switch to lightning experience.).
3. press F12 in chrome window.
4. click on console tab.
5. put the $A.get("e.force:navigateToURL").setParams(
{"url": "/apex/AccountSummary"}).fire();
//(Replace AccountSummary with the page/url you want to open).
6. press return/enter.
Note: $A is not recognized on the other pages because it's resources(libraries/assemblies/jars..) are not available there.
Also, Java Console needs to be enabled for the browser
Control Panel - Programs - Java - Advanced - Enable Java Console - Apply - OK
When i use $A.get("e.force:navigateToURL").setParams(
{"url": "/apex/HelloWorld"}).fire(); ,
it takes me to a home page instead of the HelloWorld vf page , does anyone know how to fix this?
thanks in advance!