Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7751513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T11:34:03+00:00 2026-06-01T11:34:03+00:00

Summary: 1. Need to open a new window to display a survey from a

  • 0

Summary:
1. Need to open a new window to display a survey from a third party.
2. Cannot use JavaScript to open the window (currently using target=”_blank”.
3. Must use JavaScript to track clicks (currently using onclick).
4. original window must NOT change its content upon clicking.

I have a JSP that is trying to launch a third party survey in a new window. Originally, the code was launching the new window like this:

<a id="customer_survey_button"  href="#" target="_blank" onclick="recordOutboundLink(this, 'Outbound Links', 'blah.com');openChildWindow('http://www.blah.com/f.asp?etcetera','TAKE SURVEY');return false;"  class="genbut">TAKE SURVEY</a>

It worked in FF, but not Chrome. It caused a security problem with Chrome. Something like an ‘unsafe JavaScript attempt to access a frame (new window) which loads one domain, while it’s origin is another domain. My solution was to open the window using HTML, like this:

<a id="customer_survey_button"  href="http://www.blah.com/f.asp?etcetera" target="_blank" onclick="recordOutboundLink(this, 'Outbound Links', 'blah.com');return false;"  class="genbut">Take Survey</a>

The problem is, that is not opening in a new window. During debugging, I removed the onclick from the above code, and it does open in a new window. I’m not sure if it is something wrong in the JS code…

<script type="text/javascript">
<!--
var pageTracker = _gat._getTracker("<%=googleTrackerId%>");
pageTracker._initData();
pageTracker._trackPageview();

function recordOutboundLink(link, category, action) {
  try {    
    pageTracker._trackEvent(category, action);
    setTimeout('document.location = "' + link.href + '"', 100)
  }catch(err){}
}
// -->
</script>

…or if it is just a matter of using target and onclick in the same anchor tag. Any thoughts?

I researched elsewhere, and on Stack Overflow, I found the below results, but none seemed to address this situation. For example(s):

This helped in one way, because I was able to test the removal of the “return false”. That had the same result as it did for “user1223427”- it rendered the same page in two different windows.
It did not help because I need a non-JavaScript way to open the target URL (due to the security issues mentioned).
OnClick for google analytics and target _blank. The link does not work?

This one doesn’t help, because I’m not using JQuery and I don’t understand the connection between the JQuery solution and my situation
select onclick that contains _blank

This only applies to getting tracking code to work, not issues with a new window opening:
Google Analytics – Download clicks tracking

I thought this one was going to have a good result, but it’s solution is a JS one.
Bug in external link tracking when opening the link in a new window in Google Analytics?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T11:34:05+00:00Added an answer on June 1, 2026 at 11:34 am

    The recordOutboundLink function is opening the link.

    //This is changing the URL to the href of the link you clicked    
    setTimeout('document.location = "' + link.href + '"', 100) 
    

    Your second example is returning false from the onclick event. This will prevent the anchor tag from performing it’s normal behavior.

    If you comment out the setTimeout line, and remove return false from the onclick, you should see the link behave as you want.

    You could also modify the setTimeout function to call window.open instead of document.location

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Summary: I need to login to my mailbox using EWS and but i keep
Executive summary: I need a way to determine whether a Windows process I've spawned
(Summary: My users need to be able to edit the structure of their dynamically
Summary of the problem: For some decimal values, when we convert the type from
Brief summary: I need a script/plugin for Firefox that selects the load next 25
When you open a new C# Windows Forms Application project in Visual Studio 2008,
Summary: I'm developing a persistent Java web application, and I need to make sure
I need to calculate precision and recall value in lucene and I use this
This is what I have currently: $(#cart-summary).mouseenter(function () { $('.flycart').delay(500).slideDown('fast'); }); $(.flycart).mouseleave(function () {
I'm using the FileStreamResult (or FileResult) method to display a chart on a razor

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.