-1

How do I extract a part of the URL in HTML and display the error message?

Example: URL of my web page: file_upload/code/email/Invalid_File_Type/.

I want to extract the message Invalid File Type to display the error. But how?

Using Django 1.4, I tried passing the error message from py file but couldn't get it to work for some reason :(

4

2 回答 2

0

您可以通过使用“window.location”属性并警告它来使用 JavaScript 执行此操作。

例子

<script>
alert("Your current URL is "+location);
<script>
于 2012-10-11T14:30:45.777 回答
0

我想到了!尝试这个

<script>
$(function(){
    var url = "file_upload/code/email/Invalid_File_Type/";
    var splt = url.split("/");
    var lngth = splt.length;
    var lst_value = splt[(lngth-2)]; 
    alert(lst_value);
});
</script>

这将获得网址的最后一部分。

于 2012-10-11T14:48:35.180 回答