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

  • Home
  • SEARCH
  • 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 894315
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T14:21:50+00:00 2026-05-15T14:21:50+00:00

I have two jsp(one is main page, another one is new window) and single

  • 0

I have two jsp(one is main page, another one is new window) and single javascript file.

MainPage and New Window have ‘Test’ , ‘ClickedCount’ buttons.

First, I click 3 times in MainPage ‘Test’ button . Then i open New Window.
Now , i click 2 times in newWindow ‘Test’ button.
So totally i clicked 5 times.

each time i click, i count the button click in javascript.

But mainwindow shows only 3 times, –> getTestButtonClickedCount()
And new window shows only 2 times . –> getTestButtonClickedCount()

Here i use same single javascript file (count.js)

So how to get total clickCount both window (mainWindow + NewWindow) ‘Test’ button.

MainWindow.jsp

<html>
     <head>
          <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
          <script src="count.js" type="text/javascript"></script>
     </head>
<body>
 <input type="button" value="Test" onclick="countTestButtonClick()"/>
 <input type="button" value="ClickedCount" onclick="getTestButtonClickedCount();"/>

 <a href="#" onclick = "window.open('NewWindow.jsp','newwindow',
                        'width=400,height=200')">Click to open New window</a>
</body>
</html>

NewWindow.jsp

<html>
     <head>
           <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> 
           <script src="count.js" type="text/javascript"></script>
     </head>
<body>
  <input type="button" value="Test" onclick="countTestButtonClick()"/>
  <input type="button" value="ClickedCount" onclick="getTestButtonClickedCount();"/>
</body>
</html>

count.js

var clickCount = 0;

function countTestButtonClick()
{    
    clickCount++;
}

function getTestButtonClickedCount()
{
   alert("Total Number of clicked : " + clickCount);
}

Help me about this.
Thanks for your effort.

  • 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-05-15T14:21:51+00:00Added an answer on May 15, 2026 at 2:21 pm

    Remove the JS from the newWindow and change to

     <input type="button" value="Test" onclick="opener.countTestButtonClick()"/>
     <input type="button" value="ClickedCount" onclick="opener.getTestButtonClickedCount();"/>
    

    Alternatively if one window does not open the other, use a cookie to store the clicks, reading it in and updating it and storing it each time

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

Sidebar

Related Questions

I have two jsps. One is login_first.jsp , another one is main.jsp . After
I have two pages one is the main page and the another one is
I've been having problems passing parameters from one .jsp to another. I have two
For simplicity, i have the following file named test.jsp: <script language=javascript> alert(a$b.replace(/\$/g,k)); </script> I
i have one login.jsp web page where i have two textboxes for username and
I have two list on my request on jsp. First one is productGroupName, and
I have a jsp page with two radio tags. The page contains a struts2
I have two side-by-side DIVs in a JSP. It works well, with one exception:
I have two validation jQuery functions which I need to fire one after another.
I have a page that will display one of two options for a Struts2

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.