The Javascript method is not being executed when the button is clicked

I am struggling with a form that contains buttons. Whenever I try to trigger a Javascript method using the onclick event of one of the buttons, it works perfectly fine in both Google Chrome and Internet Explorer. However, when it comes to Firefox, the onclick event fails to invoke the Javascript method.

function openHistory()
{
    window.open("frmCLogHistory.aspx?txtCLogID="+document.all['<%=txtCLogID.ClientID %>'].value, 'abc', 'fullscreen=no,top=10,left=100,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no, directories=no,location=no,width=800,height=630,titlebar=no');
}
</script>



<input type="button" name="showHistory" value="Show History"  
onclick="javascript:openHistory()" style="width:120px;"  class="GVButton" />

Answer №1

Give this a shot

function displayHistory()
{
  var elementId = document.getElementById('<%= txtLogID.ClientID %>').value;
  window.open("historyForm.aspx?txtLogID="+elementId, 'def', 'fullscreen=no,top=20,left=150,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,directories=no,location=no,width=900,height=700,titlebar=no');
}

Answer №2

When troubleshooting why your code works in some browsers but not others, such as Internet Explorer and Chrome but not Firefox, it could be due to a popup blocker specifically set up in Firefox that is preventing the window.open() function from executing properly. One way to diagnose this issue is by adding debugging code to your function like so:

function openHistory()
{
    alert('Testing window.open functionality');
    window.open( <... url ... > );
}

By including this alert message in your function, you can verify if the function is being triggered at all, indicating an issue with the window.open() call itself.

Answer №3

Update 1

How to Utilize

 <input type="button" name="showHistory" value="Show History" class="GVButton"
     onclick="javascript:return openHistory()" style="width:120px;"  />

JavaScript Function

  function openHistory()
 {
    var pageName="frmCLogHistory.aspx?";
        pageName+="txtCLogID="+document.getElementById('<%=txtCLogID.ClientID %>').value;
    var options ="fullscreen=no,top=10,left=100,toolbar=no,status=no,menubar=no,scrollbars=yes,resizable=no,directories=no,location=no,width=800,height=630,titlebar=no";
    window.open(pageName,'abc',options);
   return false;
}

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Using Google App Script for Slides to center-align text within a text box

Currently, I am tackling a project that demands the center alignment of text within a textbox on a google slide using a google app script. The primary objective is to fetch text from a google worksheet and an image from google drive. Subsequently, combine ...

Proxy-assisted database connection

Currently, I am incorporating entity framework 5.0 into my asp.net c# website endeavor. The database server is located on a remote server, while my developer machine operates behind a HTTP proxy with LDAP authentication credentials. I am seeking guidance ...

Update to the center of the JavaScript map on Google Maps

Hello everyone, While I may not consider myself a JavaScript expert, I often piece together code snippets from various sources to get things done. Currently, I am facing a challenge with styling Google maps as they don't seem to be customizable unles ...

Issue with adding a key:value pair to res.locals.object in Node/Express not functioning as expected

Currently, I am working on constructing an object within res.locals by executing multiple MongoDB operations and utilizing the next() middleware. Once I have added an object to res.locals, such as: res.locals.newObject, my goal is to subsequently add addi ...

What is the best way to utilize the initial state in my reducer file?

Every time the user clicks on <Button/>, it saves as FIRST_PERSON_CHOSEN in the database. Instead of using somebody (as defined in the reducer.js file). I want to utilize the initialState within the reducer.js file because currently it seems redund ...

Tips for avoiding page reload when submitting a form with form.submit() in ReactJs

Is there a way to avoid the page from refreshing when triggering form submission programmatically in ReactJS? I have attempted to use this block of code: const myForm = () => <form onBlur={(e) => { if(!e.relatedTa ...

What is the best way to choose all elements that fall between two specific elements?

Looking to grab content situated between two specific elements within an HTML structure. The HTML snippet in question is as follows... <h2>This is firsty</h2> <p>Some para</p> <ul> <li>list items</li> <li&g ...

tips for loading json data into jqgrid

Utilizing the struts2-jquery-jqgrid plugins, I have created a Grid with a filter-search feature. The Grid includes a drop-down list in the column assigned_user for filtering based on the selected option from the drop-down list. <s:url var="remoteurl" a ...

Adjust the alignment of radio buttons in an HTML form based on the orientation of the device

As a newcomer to HTML and jQuery, I am currently working on an html form that will be used across multiple tablets. My goal is to have the available options displayed in two rows when the tablet is in portrait mode, like this: However, when the tablet is ...

Error encountered on MongoDB with code E11000 due to duplicate key in array field

Hey there, I have a question regarding mongoose schema. Here is the code snippet: . So, I attempted to create a document without the "work" property. It worked the first time I tried it, but when I repeated the same action, it didn't work as expected. ...

An error occurred during the execution of a test case in React JS: Unexpected token

While running my test case in React JS using Jest, I encountered an error. The code in my App.test.js file is as follows: const { React } = require('react'); const { shallow } = require('enzyme'); const { Iconshow } = require('../ ...

How to Find and Count Duplicate Values in an Array using AngularJS

My form consists of 5 questions, each with 3 different answers to choose from. For example: q1. What is your favorite color? Radio button-1: blue Radio button-2: red Radio button-3: grey While most questions offer the same values (blue, red, grey), I am ...

Display search results in a GridView on a separate page upon clicking the search button

There are two pages in my website: search.aspx and show.aspx. In the search.aspx page, there are 2 textboxes and a dropdownlist for location, title, and experience. When a person clicks on the search button, if they have filled in the location textbox, t ...

JavaScript enables users to store over 5 megabytes of data on their client devices

Is there a way to store more than 5mb in the client browser? I need this functionality across various browsers including Firefox, Chrome, Internet Explorer, Safari (iOS), and Windows Phone 8 Browser. Initially, localStorage seemed like a viable option as i ...

Exploring the capabilities of AngularJS $http.post method in conjunction with

My current challenge involves using AngularJS to send an object with $http.post, along with additional data in the URL to specify the nature of the object and guide its parsing in a PHP file. I am seeking solutions on how to effectively include a variable ...

Utilize the split functionality only when the character you want to split by is found in

Consider the following situation: I have 6 string variables that contain special characters. I stored these 6 strings in an array like this: arr=[str1,str2,str3...); arr=escape(arr); due to the presence of special characters in some string variables. ...

Please ensure that the form is only submitted when at least one checkbox is selected by utilizing JavaScript

When I visit the following form: Upon filling out the details and clicking submit, if I forget to check a checkbox, a prompt appears stating "please select any one checkbox" with an 'ok' button. After clicking 'ok', the form is then su ...

An issue has occurred: The column name 'B' is not valid. This error originated from the System.Data.SqlClient.SqlConnection

I'm currently working on developing a straightforward registration page using ASP.NET C# in Visual Studio 2013. After attempting to submit the registration details for database insertion purposes, an error occurred. The error message indicated an iss ...

Executing a function upon clicking a tree node in the ASP.NET 2.0 TreeView component

I have a dynamic treeview on my website that gets populated using an XML Datasource. The issue I am facing is that when a leaf node in the treeview is clicked, it tries to open a URL in an iframe within the same page. Currently, the iframe is visible at a ...

What is the best way to conceal a form element when a specific value is present in all elements within a set?

My form consists of 3 questions with Yes/No radio options. If any of them are answered 'Yes', a 4th question will appear. However, I am facing an issue where the 4th question does not hide again if all 3 questions are reset to 'No'. Alt ...