location-href

Call django urls inside javascript on click event

你离开我真会死。 提交于 2019-12-12 08:14:36
问题 I got a javascript onclick event inside a template, and i want to call one of my django urls with an id parameter from it, like this : $(document).on('click', '.alink', function () { var id = $(this).attr('id'); document.location.href ="{% url 'myapp:productdetailorder' id %}" }); Course this is not working at all. Any idea ? Thanks in advance !! 回答1: You are trying to access javascript variable that is created at user click on frontend within your Django template at the backend. But, you

How to get values in window.location.href? [duplicate]

百般思念 提交于 2019-12-12 03:59:11
问题 This question already has answers here : How can I get query string values in JavaScript? (73 answers) Closed 6 years ago . Code: window.location.href = "Posts?Category=" + sel; How to get the value in Category page? 回答1: Try this: function getURLParameter(name, urlsearch) { return decodeURIComponent((new RegExp('[?|&]' + name + '=' + '([^&;]+?)(&|#|;|$)').exec(urlsearch || location.search) || [ , "" ])[1].replace( /\+/g, '%20')) || null; } var url = "Posts?Category=1134324"; alert

Legacy code: window.parent.location.href=“https:/home”

六月ゝ 毕业季﹏ 提交于 2019-12-11 11:20:21
问题 I have inherited some code from our former developer and I found this piece of code. <?php if($this->loginAction->isAuthenticated()){ ?> <script type="text/javascript"> window.parent.location.href="https:/home"; </script> <?php } ?> I have been looking on it for a while and I have no idea why he put there the shortcut for the URL. I think that the URL should be https://mysite.com/home. I basically don't know what does this code do. Edit: I know that this code is redirection if user is

2 Select options Combine values and link

落爺英雄遲暮 提交于 2019-12-08 03:23:52
问题 I need to combine two values and link to the selected site. ex. select> Google> select>Translate join two values T2 [translate] T1 [.google.com] = translate.google.com Go JS <script> function goToNewPage() { var g=document.getElementById('target').value; { window.location.href = document.getElementById('target').value; } } </script> HTML <form name="dropdown"> <select name="selected" id="target2" > <option selected>Select...</option> <option value=".google.com/">Google</option> <option value=

2 Select options Combine values and link

笑着哭i 提交于 2019-12-06 16:02:06
I need to combine two values and link to the selected site. ex. select> Google> select>Translate join two values T2 [translate] T1 [.google.com] = translate.google.com Go JS <script> function goToNewPage() { var g=document.getElementById('target').value; { window.location.href = document.getElementById('target').value; } } </script> HTML <form name="dropdown"> <select name="selected" id="target2" > <option selected>Select...</option> <option value=".google.com/">Google</option> <option value=".search.com/">Bing</option> </select> <select name="selected" id="target" > <option selected>Select...

create dynamic link based on text input field

主宰稳场 提交于 2019-12-03 20:28:02
问题 I'm trying to make a text input field where visitors can enter a value and then hit go or submit. Based on the digit number they would be send to a new page. For example if they enter 123 and hit submit it would send them to http://www.example.com/page/123 Could anybody please help me get this up and running? Thank you 回答1: Here we go have fun. just copy the code and save it as html. you don't need php or such. it is way too simple to need a server side code. <!DOCTYPE html PUBLIC "-//W3C/

Call django urls inside javascript on click event

流过昼夜 提交于 2019-12-03 16:18:53
I got a javascript onclick event inside a template, and i want to call one of my django urls with an id parameter from it, like this : $(document).on('click', '.alink', function () { var id = $(this).attr('id'); document.location.href ="{% url 'myapp:productdetailorder' id %}" }); Course this is not working at all. Any idea ? Thanks in advance !! You are trying to access javascript variable that is created at user click on frontend within your Django template at the backend. But, you already know that it would not work. A better option would be to reconstruct the url in javascript: $(document)

Uncaught TypeError: Undefined is not a function on indexOf

人走茶凉 提交于 2019-12-03 15:44:30
问题 I currently have this code to check the website URL GET options for a specific ID, but whenever this code is run, I get a weird error: Uncaught TypeError: Undefined is not a function Here is my code: <script language="JavaScript"> var familyid = "id=8978566"; var corporateid = "id=8978565"; if(window.location.indexOf(familyid) === -1) { document.write("Family ID not found"); } </script> It would be awesome if i could get some guidance on this issue... I couldn't find similar issues using the

FancyBox close from within iframe and take parent page to the link

℡╲_俬逩灬. 提交于 2019-11-30 06:03:17
I found applying the following function to a links onclose works to close Fancybox from within an iFrame: parent.$.fancybox.close(); I want to take this further and have the link take the parent page to a new url. I've tried the following but it doesn't work: <a onclick="location.href='http://www.domain.com/page/';parent.$.fancybox.close();"> Close and go to page</a> using a href doesn't work either as the onclose takes precedence. Very simple solution... can't believe I didn't think of this!!! <a href="http://www.domain.com/page/" target="_parent"> Close and go to page</a> Sometime, I swear I

How to pass variable to href in javascript?

北战南征 提交于 2019-11-30 03:14:29
问题 How to pass this variable value here? Below code is not working. And all other discussions on Stackoverflow are unclear. <script type="text/javascript"> function check() { var dist = document.getElementById('value'); if (dist!=""){ window.location.href="district.php?dist="+dist; } else alert('Oops.!!'); } </script> And my HTML code is: <select id="value" name="dist" onchange="return check()"> 回答1: You have to fetch field value using .value as you are passing whole object to the URL as