views:

121

answers:

1

Hi,

Hoping someone could pls let me know how to prevent the symbol "&" from being replaced by "&" within my URL, specifically within javascript?

Just to expand on requirement, I am getting my url from an oracle database table, which I then use within Oracle Application Express, to set the src attribute of an iframe to this url.

FYI, the url stored in the Oracle table is actually stored correctly, i.e.

http://mydomain.com/xml/getInfo?s=pvalue1&f=mydir/Summary.xml

what appears in my use when trying to pass over into iframe src using javascript is:

http://mydomain.com/xml/getInfo?s=pvalue1&f=mydir/Summary.xml

which basically returns a page cannot be found

Hope this clarified further my issue.

Thanks.

+3  A: 

I suspect you are doing something like this:

1) Selecting the URL text from the database into an Apex page item.

2) In Javascript, getting the URL text from the page item and using it to set the iframe source.

When you select the value in step 1, Apex will automatically replace the "&" by "&" so that the page HTML is valid - it will be something like:

<input type="hidden" id="P1_URL" 
 value="http://mydomain.com/xml/getInfo?s=pvalue1&amp;amp;f=mydir/Summary.xml" />

You will therefore have to reverse the transformation in your Javascript code - something like:

document.getElementById('myIframe').src = $v('P1_URL').replace('&amp;','&');
Tony Andrews
Hi Tony, just wondering if the .replace() call is a Apex V3.2 as I am using Apex v3.0.1 b/c I am getting a javascript error - Object exprected.
tonsils
No, the replace() call is just Javascript. More likely the problem is coming from the document.getElementById() or $v() functions, as these take a string Id and resolve it to an object.
Tony Andrews
... so in my example there must be an iframe with id="myIframe" and a *rendered* Apex page item called P1_URL on the page.
Tony Andrews
tonsils