I need run
How do that?
My code:
<script type="text/javascript">
function Detal(date1, date2){
<a id="various5" href="data/iframe.html?Detal_1=date1&Detal_2=date2">
}
</script>
If you want to do a redirect use window.location
function Detal(date1, date2){
window.location.href = "data/iframe.html?Detal_1=" +date1+ "&Detal_2=" +date2;
}
If this is not the intent, you need to explain your issue in a lot more detail
Related
I'm sorry to post with my question but I really don't understand. There are some moments like this one where I have the impression that nothing work in web.
I'm trying to do something pretty simple, I just want to reload a page and add a parameter by clicking on a button with jQuery. I searched and of course I found solutions but it doesn't work for me and I really don't understand why.
I tried several solutions but none works.
$(document).ready(function() {
$("#btnDL").click(function() {
/*window.location.href = window.location.href.replace( /[\?#].*|$/, "?dl=1" );*/
/*if(!window.location.hash) {
window.location.replace(window.location.href + "?dl=1");
}*/
/*var url = new URL(window.location.href);
url.searchParams.set('dl','1');
location.reload();*/
var url = window.location.href;
url += '?dl=1'
window.location.href = url;
});
});
Here is my code (I let some solutions I tried in comment), this doesn't work, when I click on my button it just refresh the page but the URL is still the same.
I think you've seen this question a lot of times so sorry for the inconvenience.
Thank you
$(document).ready(function() {
$("#btnDL").click(function() {
var url = window.location.href;
window.location.href = window.location.href + "?dl=1";
});
});
try this
I have tested it on Google Chrome and it is appending id with the url. Try it:
<html>
<head>
<script
src="https://code.jquery.com/jquery-3.3.1.js"
integrity="sha256-2Kok7MbOyxpgUVvAk/HJ2jigOSYS2auK4Pfzbm7uH60="
crossorigin="anonymous"></script>
<script>
$(document).ready(function() {
$("#btnDL").click(function() {
var url = window.location.href;
alert(url);
url += '?dl=1'
window.location.href = url;
})
});
</script>
</head>
<body>
<button id='btnDL'>
Click Me
</button>
</body>
</html>
The question is how to create a button that retries connection to a website. The non working is:
Retry/Refresh
try window.location.reload(true)
documentation
The working code should be:
<button onclick="retryConnect()">Retry</button>
<script>
function retryConnect(){
location="retry.html";
}
</script>
Create a file called retry.html in the same directory, and write in it:
<p onload="loadPage()">Please wait...</p>
<script>
var delayLoad;
function loadPage() {
delayLoad = setTimeout(showPage, 1000);
}
function showPage() {
location="the previous page";
}
</script>
how can I run Function in original page from window.open
original_page.html
<div id="Processing" style="display:none;">
<button onclick="window.open("Processing_window.html")">open</button>
</div>
<script language="JavaScript">
function submit_form() {
var upgradeForm = document.getElementById('upgradeForm');
setTimeout("upgradeForm.submit()",3000);
}
</script>
========
Processing_window.html
<script language="JavaScript">
function Processing_window() {
var doc = window.opener.document, Processing = doc.getElementById("Processing");
Processing.style = '';
submit_form(); //Here the problem
window.close();
}
setTimeout ("Processing_window()",5000);
</script>
========
I went to run "submit_form();" funcion from Processing_window.html
To access functions from the opener, use window.opener.functionName, assuming both are in the same domain.
function Processing_window() {
var doc = window.opener.document, Processing = doc.getElementById("Processing");
Processing.style = '';
// Here's the solution
window.opener.submit_form();
window.close();
}
setTimeout ("Processing_window()",5000);
You need to HTML encode the quotation marks in the code in the attribute, or use apostrophes:
<button onclick="window.open('Processing_window.html')">open</button>
As long as the page that you open has the same origin (same server, same protocol), you can use the opener property to access the parent windows window object. There's where you find the reference to the function:
window.opener.submit_form();
You can, but not cross-domain. Only in the same domain.
<script>
function new_win_fun() {
var wind = window.open("Processing_window.html");
var upgradeForm = wind.document.getElementById("upgradeForm");
wind.setTimeout("upgradeForm.submit()",3000);
}
</script>
<button onclick="new_win_func()">Run</button>
I am wondering if someone can spot the mistake in my code?
javascript:
function decodehtml(thestring){
var decoded = $("<div/>").html(thestring).text();
alert(decoded);
return decoded;
}
inside html:
<script type="text/javascript">
decodehtml("test string");
</script>
I know it is both returning and alerting, the alert is in there just for the test. For some reason this is doing nothing.
Any ideas?
Simon
Edit:
Even placing this directly into the html does not work:
<script type="text/javascript">
var decoded = $("<div/>").html("test string").text();
alert(decoded);
</script>
function decodehtml(thestring) {
var decoded = $("<div/>").html(thestring).text();
alert(decoded);
return decoded;
}
decodehtml("stuff");
Seems to work fine. Here's the jsFiddle
$ is not defined
This means you are not including jQuery. Place this in your head tag :
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
And then put your code.
Hey I have a function which is called from a html link like this:
<a href='#' onclick='javascript:populate("m")'>My Messages</a><br/>
Function called:
function populate(q){
switch(q){
case 'm': messages_document(call_data(q+'.php','main')); break;
}
return (false);
}
The problem i have is the url in the browser adds a # to the it - which seems to prevent me clicking the link again unless i remove the hash, is there a way to stop it loading in the browser url ?
onclick='return populate("m");'
Load your script in the document head(that is, stuff it between two <head> and <script type="text/javascript"> tags). Example:
<head>
<script type="text/javascript">
function test(id){
alert(id);
}
</script>
</head>
My Messages​
I've tested it and it works fine.
try
My Messages
<script>
function populate(q) {
switch(q) {
case 'm': messages_document(call_data(q + '.php', 'main')); break;
}
}
</script>