jQuery $(location).attr('href',URL) not working as desired
Hi Team,
My requirement seems to be simple, straightforward... have a submit button within a custom widget consuming a javascript to collect some information from HTML content and redirect web user to an external page... but redirect doesn't work at all. I tried both javascript and jQuery techniques.
Is there any restriction on Sitefinity blocking redirects to external URL?
Carlos.
Carlos,
window.location.href =
"http://www.sitefinity.com"
;
$(location).attr(
'href'
,
'http://www.sitefinity.com'
);
<
sf:ResourceLinks
ID
=
"resourcesLinks"
runat
=
"server"
>
<
sf:ResourceFile
JavaScriptLibrary
=
"JQuery"
/>
</
sf:ResourceLinks
>
<
script
src
=
"/Sitefinity/WebsiteTemplates/Custom/App_Themes/Default/JS/jquery-1.7.1.min.js"
></
script
>
<!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if offline -->
<
script
src
=
"//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"
></
script
>
<
script
>window.jQuery || document.write('<
script
src
=
"/Sitefinity/WebsiteTemplates/Custom/App_Themes/Default/JS/jquery-1.7.1.min.js"
><\/script>')</
script
>
Hi Tim,
Weird but it doesn't work for me. I tried both JavaScript and jQuery approaches and web browser remains on same page, it doesn't change to desired URL, ie http://www.sitefinity.com. Notice that I've no JavaScript errors but no web browser navigation at all. My workaround will be trying open a new window instead.
Thanks.
Hi Tim,
I realized my basic-beginner mistake... I missed the "; return false;" command immediately after javascript method call, I was immerse on javascript logic and location change was the last line of code I had to enter to complete this task.. Thanks!