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 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 problems. The first one is that I'm using JSP and that
I have two db tables. One table contains Forecast data. The second table contains
I have a simple html page where I pass two values, a name (
I have a JSP file which I am deploying within a Java Project with
I have a table in Microsoft SQL server Management Studio with two columns title
I am working on a legacy jsp web application that uses JDBC and inline
I currently have a search box in our admin navigation that is submitting to
in a JSP I should print the values of an array list in the
Here's the thing, In order to imitate the way grails does multiple submits for
I am having a weird problem here, and I am really stuck, need to

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.