I've got a function that is called by a press of a button that is
function DownloadBase() {
window.location.href = "../direct-download?variant=base"
}
and I wanted it to open the direct-download/index.html with the queries variant=base
Resould should be: https://domain/direct-download?variant=base
But instead I get it without the query options.
Is it possible to do? Am I missing something?
Thanks
Related
I just started to work with fine-uploader because it looks really great.
But of course that i have a problem. I would like to send 1 more parameter when you click on DELETE button. This parameter should be the name of the image that will be deleted.
What i don't know is how to get that name. i Tried to add onclick event as a parameter in html element but there is a problem with timing because of async.
In code i found only this:
where {filename} represents name of the image, but i have no idea, how to add it here:
Any help will be appreciated
To add parameters to the delete file request dynamically (per-file or for all files) use the setDeleteFileParams API method. For example:
callbacks: {
onSubmitDelete: function(fileId) {
var fileName = this.getName(fileId);
this.setDeleteFileParams({fileName: fileName}, fileId);
}
}
try this to get file name
//Using jQuery
$("#fineUploader").on("onSubmitDelete", function(event,id,name){
file_name = $(this).fineUploader("getName", id);
})
I'm trying to create a "Back" button as a function or directive. Upon clicking it, it would call a function that has several things to do before redirecting the user to a url.
Normally, in pure JS, I would have a simple div with an onclick function to which I would pass the URL to go to then the function would do its thing then make a window.location.href = url and it would be ok.
Here in angular, the URL i'm trying to send is part hardcoded, part coming from a ng-model: url="#/clients/editer/{{client._id}}"
When trying to use a simple function to which I would pass this as a string, my function doesent get the client.id as a string though the HTML inspector of firefox says it does. But if I console.log the URL the function gets, it says
"#/clients/editer/{{client._id}}" instead of "#/clients/editer/56684b4fe7b59ff020b85590"
When trying to use a directive instead of a function, as being new to all this, I dont understant how I'm supposed to pass thir URL to the directive. Since the URL could change radically from a module to another (from "#/clients/editer/{{client._id}}" to "#/materiel/editer/{{materiel._id}}", I need to pass the decoded URL directly to the directive which would then execute the onclick function.
Hope someone can help me !
I made simple test code
js
scope.client._id = 9;
scope.somefunction = function (url){
console.log(url)
}
Html
<div ng-click="somefunction('#/clients/editer/{{client._id}}')">link</div>
Result: #/clients/editer/{{client._id}}
<div ng-click="somefunction('#/clients/editer/'+ client._id)">link</div>
Result: #/clients/editer/9
Is this the result you wanted to achieve?
I have problem when I send a value to the url with jQuery load function
function close_session(ruta)
{
jQuery("#lcload").load(ruta + "/mod_register/test.php?action=close_session").show(3000);
}
I call this function from link onclick, the problem is with "ruta", if I writte the value of "ruta" in the script I don't have problem and the url is loaded correctly, the problem is when I want to send the value of "ruta", when I click the link the script doesn't load the content. So, I can't find the problem. I donĀ“t know if I'm writing something wrong. I appreciate any help
Best Regards
Try with "/" before modules:
have you tried passing in a second argument as an object instead of url params?
jQuery("#lcload").load(""+ruta+"/mod_register/test.php", { action: "close_session"} ).show(3000)
I have a link in an e-mail that points the user to a webpage. On this webpage there is a pop-up that is hidden, unless a button is clicked; then jQuery displays that div.
I have searched for a way to grab the query string from the URL with jQuery to no avail. I know with PHP it would be a simple $query = $_GET['query'], but I'm not sure how to accomplish this with jQuery.
I need to check for a query string, say "?popUp=true", and display that div with jQuery if the query string is present.
Is there a way I can pass the PHP GET variable to jQuery?
I'm confused.
jQuery has nothing to do with it; it's just plain Javascript:
var query = window.location.search;
Or simply location.search. Do window.location from the Javascript console to see what all is there.
So:
$(document).ready(function(){
if (location.search.indexOf('popUp=true') > -1)) {
doPopUp(); // run your code.
}
});
MDN
Of course, we can get query parameter from url by split it, and it's pure java script. There's a general way to do it: http://www.jquerybyexample.net/2012/06/get-url-parameters-using-jquery.html
But if you just need [popup=true] to use with jquery, you'd better to use hash.
URL:
http://.../yourscript.php#popup
And your jquery code:
if(window.location.hash) {
// Fragment exists, show popup
} else {
// Fragment doesn't exist, do nothing
}
I have a script that loads the code dynamically. It is kind of a search engine. When I press a search button, the action gets triggered and a new page opens with many parameters.
I want to override one of the parameters generated with the script in the new URL. JS code is quite big and hard to read, but I have found the important part in the Firebug DOM editor.
This is the pattern of the URL generated when you perform the search:
http://www.example.com/...?ParameterOne=123&ParameterTwo=Two&ThisParameter=Sth&ParameterFour=Four...
What I want to edit is "ThisParameter" and change its value. This is the part edited in the DOM that does what I want:
Foobar = {
_options: [],
...
var options = {"ParameterOne":123,"ParameterTwo":"Two","ThisParameter":"ABC","ParameterFour":Four,...}
...
And this is the output of "ThisParameter" when you choose "Copy path" in Firebug's DOM tab:
_options[0].ThisParameter
I am wondering it this is possible at all. What makes me think that it is, is the fact that I can change this parameter in Firebug and it works perfectly. So, if Firebug can edit it, there should be a way to influence it with another script.
Looking forward to any suggestions, thank you in advance!
Since you cannot edit the dynamic script you have the following options:
You have to try to give the script the correct input and hope it uses your value.
Add a script to the results page which will read the url and arguments, change it and redirect, as we discussed here. (If you put everything in functions it should not conflict with the dynamic script if the functions are uniquely named.)
You could try adding something like this jQuery code to the page with the search button:
$('input[name=search_button_name]').click(function(e) {
e.preventDefault();
var form_search = $('#search_form_id');
$('<input>').attr({
type: 'hidden',
name: 'ThisParameter',
value: 'SomethingElse'
}).appendTo(form_search);
f.submit();
});
You can override any js function and method, or wrap you code around it. The easiest thing would be to look at the code you get and once it gets loaded, you re-declare a method with your own functionality.
I you are trying to replace a parameter in a specific jquery request, you can even wrap around the jquerys ajax method:
var jquery_ajax = $.ajax
$.ajax = function(options){
// parse only a specific occurence
if(options.url.indexOf("example.com") > -1) {
// change the url/params object - depending on where the parameter is
options.params.ThisParameter = "My Custom value"
}
// call the original jquery ajax function
jquery_ajax(options);
}
But it would be a lot cleaner to override the method that builds the ajax request rather than the ajax request itself.
I would investigate further on the scope of the variable options (var options), is it global? i.e. if you type 'options' in the Firebug console, does it display its properties?
If so, you could then access it via your own script and change is value, e.g.
options.ThisParameter = 'my-own-value';
You might hook your script to the click event of the search button.
I hope this helps, it could be more specific maybe if you have some sample code somewhere.