Leveraging JavaScript to attach/append a query parameter to a URL

Currently, I am working with the DNN CMS platform and utilizing a module called ActionForm provided by DNNSharp to generate forms.

Although there is an option in this module to display a form in a popup, I am facing a challenge in passing a query string to the popup URL using this method.

The HTML code snippet related to this issue looks like this:

<a href="javascript: showFormPopup1163();">Link Title</a>

Whenever I try to add ?mystring=[mytoken] at the end of the href attribute, it causes the link to stop functioning.

After some research, I have come across information suggesting that adding the query string to the popup URL can be achieved using JavaScript.

I came across this topic on Stack Overflow but I am uncertain whether it provides a solution applicable to my situation and how to actually implement it:

Add Query-String parameter to static link on click

Would inserting that particular code into script tags within my HTML code resolve my query string dilemma?

Any assistance or insights on this matter would be greatly appreciated.

Many Thanks, Alex

Answer №1

I achieve this by utilizing History.js

It is uncertain if ActionForms includes a feature that enables the inclusion of external scripts, but assuming you can integrate history.js, you can implement something similar to the following:

var queryStringParams = '?mystring=[mytoken]';
var dataObj = '{ mystring: [mytoken] }';
var titleText = 'Form with token: [mytoken]';
History.pushState(dataObj, titleText, queryStringParams);

This action will modify the URL without re-loading the page and will also permit users to navigate back to the previous URL using the browser's back button, all while maintaining the original query string.

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

JavaScript does not allow for the incrementation of a global variable within a function

Imagine I have some JavaScript and HTML code like this: var x = 1 function increase() { x += 1 console.log(x) } <button onclick="increase()">Click</button> When the button is clicked, x increases to 2 but doesn't go any higher ...

Automatically injecting dependencies in Aurelia using Typescript

Recently, I started working with Typescript and Aurelia framework. Currently, I am facing an issue while trying to implement the @autoinject decorator in a VS2015 ASP.NET MVC 6 project. Below is the code snippet I am using: import {autoinject} from "aure ...

React's useState feature is doubling the increment

I have created a basic form management system with a historical feature. A simplified version of this system can be seen on codesandbox import { useState } from "react"; import "./styles.css"; const sample = ["what", "w ...

Is there a way to determine the duration that a click was held down for?

When triggering an onClick event, I want to determine whether it was a single click or if the mouse button was held down for some time before releasing. This way, I can call the myTest() function within onClick="myTest()", which will log "mouse was click ...

Styling Bootstrap radio toggle buttons using CSS

I am currently utilizing Bootstrap version 3.37 and have implemented two toggle buttons for users to select from. My goal is to have the "active" state assigned to the blue button when clicked, displaying a dark color. Conversely, when the green button is ...

Experiencing a Number TypeError Issue with Mongoose Schema?

The server encountered a 500 internal error with the message: Error: TypeError: path must be a string The specific line causing the error in ItemCtrl.js is line 35. console.log('Error: ' + data); The stack trace for this error is as follows: ...

Development of Chrome Extensions, JavaScript dilemma

Hey there, I'm new to JavaScript and I've been diving into the world of creating Chrome extensions. I'm trying to set up a content script and browser action, but I'm struggling to get it up and running. I know I'm probably making a ...

I am receiving an error stating "Page not found" when making an AJAX request. What could be causing

Whenever I attempt a POST request, I consistently receive the 'Requested page not found. [404]' error message. I am unable to identify the root cause of this issue, so please provide your guidance and advice. I have developed a web API using ASP ...

When the `back` button is clicked in a browser from a different domain, does it trigger a page reload?

Imagine a scenario where a user accesses mydomain.com. At this point, the history stack contains only one entry. Then, the user clicks on a link within my website that leads to mydomain.com/cool, causing another state to be pushed onto the stack. Now, with ...

JQuery post will not be able to retrieve from Asp.Net SQL Session Mode

While working on my Asp.net Mvc mobile application with jQuery on the front end, I encountered an issue where it seemed to be losing session variables. To address this, I decided to change the session state from in-process to SQL Server. After running the ...

Converting an ASP.NET web form into a serialized format

Is there a way to serialize an ASP.NET web form along with all the user-entered data? I am looking for a method to allow users to save partially completed forms, and I was thinking serialization might be the way to go. Any helpful examples would be highly ...

Verify whether the division contains any elements and does not include specific elements

I previously opened a similar thread, but with the condition that the div does not contain a second element within it. So my previous question was as follows: I have some code that looks like this: <p class="elementWrap"> <label>Phone</l ...

Send nodejs express static request over to secure https server

Is there a way to ensure all HTTP requests, including those for static files, are redirected to HTTPS? This is the code I currently have: app.use(express.static(__dirname + '/public')); app.get('*', function(req, res) { if (!req. ...

Google Maps API displaying empty spots instead of markers

I am facing an issue with my webpage where the Markers are not showing up, despite troubleshooting for many hours. The parsing php file has been confirmed to be working. Below is the code: <script src="https://maps.googleapis.com/maps/api/js">< ...

Executing several conditional calls in RxJS

I am currently facing an issue with conditional calls in RxJS. The situation involves multiple HTTP calls within a forkJoin. However, there are dependencies present - for example, the second call should only be made if a boolean value from the first call i ...

Interactive Image Modal with Zoom In/Out feature

I'm struggling to figure out how to do this. Can anyone provide a helpful example of how to implement a zoom in and out pop up modal for an image? My current project is based on asp.net and vb.net for user interface and coding, but I haven't had ...

Is there a way to prevent ng-template-loader from scanning image src's?

Currently, I am beginning to incorporate webpack into my development workflow for an angular project. To create my templateCache, I have had to include the ng-template-loader. Below is a snippet of my webpack configuration: { test: /\.html$/, loa ...

Show JSON array items

My php file (history.php) generates a JSON object $i=1; $q=mysql_query("select * from participants where phone='".mysql_real_escape_string($_GET['phone'])."' limit 10"); while($rs=mysql_fetch_array($q)){ $response[$i] = $rs[&ap ...

Can the variables in Bootstrap be altered dynamically during runtime?

Is there a way to dynamically change the Bootstrap color variables during runtime? I am working with Orchard Core and would like to develop a Bootstrap module that allows users to select colors within the admin area. Additionally, I want to be able to re ...

Perform the function with the value of the currently selected option

Despite selecting an option, a message still appears stating "Please choose something." This function works with only one dropdown list, but encounters issues when there are two or more. (In this example, the variable 'sport' is document.getElem ...