title: Passing SF variable value to jQuery value to use in link
body: <p>I need some assistance on this issue because I have searched online and tried different things for almost three hours and so far nothing has even slightly worked.</p>
  
  <p><strong>Here is what I am trying to do:</strong>
  I built a custom VF page that uses custom css. The page sections are contained in components. In my header component I have a HTML link that is formatted to look like a button. When the user clicks that button then they should be taken back to the Opportunity record they came from. I am unable to retrieve the ID of the opportunity using jQuery and no matter how many times/things I try, this is what the link looks like (<em>/%7B!oppId%7D</em>)</p>
  
  <p>I would appreciate any help on this matter as I seem to be stuck!</p>
  
  <p>Thanks :)</p>
  
  <p>PAGE CODE:</p>
  
  <pre><code>&lt;apex:page standardController="Opportunity" extensions="DEMO_ScheduleOpportunityController" showHeader="false" sidebar="false" standardStylesheets="false"&gt;
  &lt;head&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;header id="header-section"&gt;
          &lt;c:DEMOscheduleHeader opportunity="{!opportunity}" /&gt;
      &lt;/header&gt;
      &lt;apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js" /&gt;
      &lt;apex:includeScript value="{!URLFOR($Resource.DEMO_Schedule, 'js/page.js')}" /&gt;
  &lt;/body&gt;
  &lt;/apex:page&gt;
  </code></pre>
  
  <p>COMPONENT CODE:</p>
  
  <pre><code>&lt;apex:component&gt;
  &lt;apex:attribute name="opportunity" type="Opportunity" required="true" description="This is Opportuinity used by the Schedule" /&gt;
      &lt;a href="#" id="exit" class="btn"&gt;Exit&lt;/a&gt;
  &lt;/apex:component&gt;
  </code></pre>
  
  <p>CONTROLLER CODE:</p>
  
  <pre><code>public with sharing class DEMO_ScheduleOpportunityController {
      public Opportunity opportunity {get; set;}
  
      public DEMO_ScheduleOpportunityController(ApexPages.StandardController controller) {
          Initialize();
      }
      public void Initialize() {
          opportunity = [SELECT Id FROM Opportunity WHERE Id = :ApexPages.currentPage().getParameters().get('id')];
      }
  }
  </code></pre>
  
  <p>JS CODE:</p>
  
  <pre><code>$(document).ready(function() {
      var oppId = '{!oppId}'; // the Opportunity Id
      var exitURL = "/" + oppId; // creating and forming the exitURL
      document.getElementById('exit').href = exitURL; // assigning the exitURL to the Exit Button
  });
  </code></pre>