salesforce - How to import a javascript file in Visualforce Markup? -


How to import a file into VisualForce markup? I am trying to refer to a stable resource in Salesforce with the URL form function.

The following script works

  & lt; Top: Page & gt; & Lt; Html & gt; & Lt; Body & gt; & Lt; H1 & gt; My first JavaScript & lt; / H1> & Lt; P & gt; Click the date to display the current day, date and time. & Lt; / P & gt; & Lt; Button type = "button" onclick = "myfunction ()" & gt; Date & lt; / Button & gt; & Lt; P id = "demo" & gt; & Lt; / P & gt; & Lt; Script & gt; Function myFunction () {document.getElementById ("Demo"). InnerHTML = Date (); } & Lt; / Script & gt; & Lt; / Body & gt; & Lt; / Html & gt; & Lt; / Supreme: Page & gt;  

However, I use VisualForce

  & lt; Top: Page & gt; Refer to the function within and want to implement the following. & Lt; Html & gt; & Lt; Body & gt; & Lt; H1 & gt; My first JavaScript & lt; / H1> & Lt; P & gt; Click the date to display the current day, date and time. & Lt; / P & gt; & Lt; Button type = "button" onclick = "myfunction ()" & gt; Date & lt; / Button & gt; & Lt; P id = "demo" & gt; & Lt; / P & gt; & Lt; Top: Included script value = "{! URLFOR ($ Resource.SalesDashboard, '/js/datefunction.js')}//group; & Lt; / Body & gt; & Lt; / Html & gt; & Lt; / Supreme: Page & gt;  

I have also tried:

  & lt; Top: Page & gt; & Lt; Html & gt; & Lt; Body & gt; & Lt; H1 & gt; My first JavaScript & lt; / H1> & Lt; P & gt; Click the date to display the current day, date and time. & Lt; / P & gt; & Lt; Button type = "button" onclick = "myfunction ()" & gt; Date & lt; / Button & gt; & Lt; P id = "demo" & gt; & Lt; / P & gt; & Lt; Apex: Included script value = "{resource! Resource_dashboard}" /> & Lt; / Body & gt; & Lt; / Html & gt; & Lt; / Supreme: Page & gt; According to  

The best way to incorporate JavaScript is by using VisualForce The page is keeping Javascript in a stable resource, then calling it from there. For example,

  & lt; Top: Included script value = "$ {Resources $$$$$$}" />  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -