Javascript - Assigning Location.href, Explain Url Encoding (in Asp.net And Firefox)?

Jan 22, 2010

In some javascript, I have:var url = "find.aspx?" + "location=" + encodeURIComponent( address );
alert( url );location.href = url;where the value of address is the string "Seattle, WA".

[code]...

So I'm getting three different representations whereas I would expect that in all three places I should see what I see in the alert. My expectation is that the url I assign to location.href should show up as-is in the browser url window, and should be passed as-is to the server in Request.Url (and I would need to decode the values on the server before using them).What's happening?

View 3 Replies


Similar Messages:

C# - Javascript:window.location.href Opens New Tab In Firefox And New Window In IE?

Apr 4, 2011

lstItems.Attributes.Add("onclick", "javascript:window.location.href='" + Project2.Constants.MySiteURL + "myPage.aspx/" + ID + "';");

edit:-

i found this solution on SO but dont know how to use it in my case :

window.open("http://asdf.com", "window_name","location=1,status=1,scrollbars=1,resizable=no,width=650,height=650");

edit 2 :-

Any Javascript expert in here ?

edit3 :-

@Headshota:: Its still opening in new tab in firefox and as apop up window in IE :(

edit 4 :-

@ Craig :: What does this mean? "possibly got a misplace target="_blank" somewhere" How do i check for it?

View 2 Replies

Web Forms :: Window.location.href Don't Work On Enter Key

Mar 17, 2010

I created a search functionallity for a client site but cannot get this Enter key search to navigate to my search box. I added HTML client controls as to server controls:

[Code]....

My Javascript does fire on enter key, and it does call the "searchProducts" method but not navigating to my desired location. Here is the Javascript:
function searchKeyPress(e) {
if ((e.which && e.which == 13) || (e.keyCode && e.keyCode == 13)) {
$('#go').click();
return false;
} else {
return true;
}
}
function searchProducts() {
var searchVal = $('#s').val();
var concLoc = [URL]
window.location.href = concLoc;
}

View 12 Replies

Window.location.href Not Working In Safari When Using Onkeypress?

May 6, 2010

I'm using an asp textbox and a search button. In Safari if I click the search button i get redirected to the search results page using javascript window.location.href. But strangely the same javascript will not redirect to the page if I press return in the textbox. Using the alert function I can see that window.location.href has the the correct url and the location bar at the top changes from the search page(default.aspx) to the search results url however when I click OK to the alert box the url at the top reverts back to the default.aspx page. It works on ie7/8/firefox/chrome but not safari. Here is my javascript,cs and aspx code:

function submitSearchOnEnter(e) {
var CodeForEnter = 13;
var codeEnteredByUser;

[code]...

View 3 Replies

Explain This Seeming Inconsistency In JQuery/Javascript? (trailing Brackets Inconsistency On Reads)

Feb 18, 2010

So, in my example below, "InputDate'" is an input type=text, "DateColumn" is a TD within a table with a class of "DateColumn".

Read the value of a discreet texbox:

var inputVal = $('#InputDate').val();


Read the value of a div within a table....

This works:

$('#theTable .DateColumn').each(function() {
var rowDate = Date.parse($(this)[0].innerHTML);
});

This doesn't:

$('#theTable .DateColumn').each(function() {
var rowDate = Date.parse($(this)[0].innerHTML());
});

The difference is the "()" after innerHTML. This behavior seems syntactically inconsistent between how you read a value from a textbox and how you read it from a div. I'm ok with sometimes, depending on the type of control, having to read .val vs .innerHTML vs.whateverElseDependingOnTheTypeOfControl...but this example leads me to believe I now must also memorize whether I need trailing brackets or not on each property/method.

So for a person like me who is relatively new to jQuery/Javascript....I seem to have figured out this particular anomaly, in this instance, but is there a convention I am missing out on, or does a person have to literally have to memorize whether each method does or does not need brackets?

View 2 Replies

Add A HREF Using Javascript?

Mar 16, 2011

I have an ASP.NET 4.0 site that has links to another ASP.NET site (different domain name). In situations where users from domain 1 are directed to a page on domain 2, how would I setup a Javascript routine to create an href back to domain 1? That is, I don't want to place a solid <a> tag on domain 2 pointing back to domain 1. Rather, I need a little bit of script magic that only makes the href available to users coming from domain 1. specific Javascript library/widget that functions in this manner?

View 1 Replies

JavaScript - Disable Anchor Tag If Href Is Empty?

Mar 2, 2011

I have an ASP.NET Menu which generates many anchor tags when rendered.

My requirements were

to prevent postback if href or an anchor tag is "" or "#". to make the cursor not to show the hand First I checked the markup of one of the generated anchor tags

[code].....

When I hovered on the empty link, the cursor is showing the default one instead of hand, that means my anchor is recognized. But when I clicked the anchor, postback occurred!

Tried replacing anchor.unbind('click'); with anchor.kill('click');
Tried replacing e.preventDefault(); by appending e.stopPropogation and even return false;
Tried replacing anchor.bind('click', function(e){ with anchor.click(function(e) {

Nothing seems to work. What could be wrong with my code?

View 3 Replies

How To Break Line While Assigning Value Using Javascript

Oct 11, 2010

i ve a string like

var Ans="a<br>b<br>c";

wen i assigned input using document.getElementById(id).value = Ans;

it display input as it is

i wanna show input lyk

a

b

c

i am tryin to replace <br>wit " " but it is not working... it is showing

a<br>b<br>c or

a
b
c

View 3 Replies

C# - Deal With Different Kinds Of Encoding In The Javascript?

Sep 8, 2010

I recognized that based on a context in which I want to use some parameters, there are at least 4 kinds of encoding that are necessary to avoid corrupted code being executed :

Javascript encoding when constructing a javascript code, e.g.
var a = "what's up ?"
var b = "alert('" + a + "');"
eval(b); // or anything else that executes b as code

[Code]....

View 3 Replies

Javascript - Client Side Href Lost / Want To Send It Back On Postback?

Dec 30, 2010

I'm losing client side href. Is it possible to send it back to the server on the button submit using a variable or something?

View 1 Replies

Webmailer Encoding Characters / Set The Content Encoding Of The Whole Page?

Jan 4, 2010

I have written a web mailer that can send and receive emails and display them on a webpage.I have a problem displaying special characters though. Like Russian, and Greek and chinese.I am using openpop.net and I can get the encoding of the incoming email as one of my variables.Thing is, how do I display it? Do I set the content encoding of the whole page to what that specific email encoding is?I've got it UTF-8 at the moment and I get garbage.

View 3 Replies

Web Forms :: Javascript - Set Source File And Assigning Value To A Hidden Field Control

Oct 8, 2010

have a tree view control build dynamically. i want to change color of the selected node from client side. write the script given below. and its work fine.

[Code]....

[Code]....

[Code]....

View 1 Replies

MVC :: Encoding Whitespace / Not Encoding The < As A Encode But Into The Form <?

Jan 5, 2010

Im pulling out a text field from the database which has and 's in it for line breaks. Which I have left there for pupose of being able to edit the fields later on.

So when i try to display the text I need to replace them which I have done with:

[Code]....

Simple enough. Only when I run the page the source code I get for it is:

<br />

So it seems its not encoding the < as a encode but into the form <

Does anyone know how to stop this happen. Or a method around it?

View 3 Replies

Security :: Automatically Assigning Roles / Standard Practice For Assigning Roles To Newly Signed-on members?

May 17, 2010

Newb question: what is the standard practice for assigning roles to newly signed-on members. Is it usually manual or is there a way of automatically assigning roles. Being completely new to this, I am confronted by the issue of my site having three different roles that new members could fall into, but am unsure about how to assign each a role. I can't imagine having to go through the process manually if I have thousands of members.

View 6 Replies

MVC :: Finding Image Location In JavaScript?

Dec 30, 2010

I created a HTMLExtension method for a DatePicker. I reference it from the view as follows (see bolded text for image location):

[Code]....

The HTMLExtension method:

[Code]....

Everything works when run on the development server but when run with IIS, the image is not found. Generally I would use "Url.Content" to fix these problems but I can't place that in the Javascript.

View 9 Replies

Javascript - Location Of Image Resources?

Feb 24, 2011

I have a plugin that runs off my customer's websites. The plugin is at [URL], and needs to pull in some images. The problem is that the javascript seems to try to pull images from the customer's site, rather than from my own site. Here is the JS:

button.style.cssText = 'position:absolute;top:-20px;right:-20px;background-image:url(/Resource/Button.png);

In the above JS, the retrieval URL is CUSTOMER.com/Resource/Button.png (the site where the plugin runs), rather than my sites mycompany.com/Resource/Button.png.

Note that I cannot use absolute paths, as they become a pain between environments (test/prod) and also because my image retrieval must use http/https based on the client environment (otherwise you can errors if http is used on an https site).

View 4 Replies

Dictionary Explain Method?

Jan 20, 2011

can anyone explain what this method does exactly. Here what I can tell.ine 1 a dictionary object is createdline 2. it iterate through the Datarowline 3 . it adds first column name and value of the first row to other dictionary object fsline 4 & 5 here where I got lost, do not know what the code is ment to do , please explain also, can you go over the first two iteration word by word so i can follow up with you

protected Dictionary<string, object> fields(DataRow dr)
{
1 Dictionary<string, object> fs = new Dictionary<string, object>();
2 for (int i = 0; i < dr.ItemArray.Length; i++)
[code]...

View 2 Replies

Javascript - Unload In Firefox?

Oct 11, 2010

I have a client register startup script like so:

" " +
"document.body.onunload =
clearSession; " +

[code]...

View 1 Replies

.net - Javascript Not Executed In Firefox?

Mar 25, 2011

Open new popup window without address bars in firefox & IE

I have the following code which works in ie(no addressbar, status bar, etc but not firefox..

function popUpDetails(trackNum) {
var newWindow = (window.open('popUpDetails.aspx?trackNum=' + trackNum, 'Title', 'width=540,height=265, location=no, menubar=no, status=no, toolbar=no, scrollbars=no, resizable=no, modal=no'));
}

View 1 Replies

Explain File Locations Dll, Applications Etc?

Feb 10, 2011

Can you point me to a site where someone can explain file locations dll, applications etc. I guess it was too easy with asp classic to drop a file in a folder. How does all this file management work with aspx?

View 3 Replies

AJAX JavaScript Files Served From A Static Location?

Jan 5, 2010

I realise that this is going to be a fairly niche requirement and will almost certainly raise a few "WTF's" but here goes...

Within an ASP.NET Webforms application I need to serve static content from a local client machine in order to reduce up-front bandwidth requirements as much as possible (Security policy has disabled all Browser caching). The idea is to serve CSS, images and JavaScript files from a location on the local file system referenced by filesystem links from within the Web application (Yes, I know, WTF's galore but that's how it is). The application itself will effectively be an Intranet app that's hosted externally from a client but restricted by IP range along with standard username/password security. So it's pretty much a hybrid Internet/Intranet application but we can easily roll out packages of files to client machines. I am not suggesting that we expect nor require public clients to download packages of files. We have control to an extent over the client machines in terms of the local filesystem and so on but we cannot change the caching policy.

We're using UpdatePanel controls to perform partial page updates which obviously means that we need to Microsoft AJAX JavaScript files. Presently these are being served (as standard) by a standard resource handler within IIS/ASP.NET. Ideally I would like to be able to take these JS files and reference them statically from a client machine, and no longer serve them via an AXD.

My questions are:Is this possible?If it is possible, how do we go about doing so?

In order to attempt to pre-empt some WTF's the requirement stems from attempting to service a requirement with as little time and effort as possible whilst a more suitable solution is developed. I'm aware that we can lighten the load, we can switch to jQuery AJAX updates, we can rewrite the front-end in MVC etc. but my question is related to what we can quickly deploy with our existing application architecture.

View 2 Replies

Javascript - Validators Broken In FireFox?

Oct 4, 2010

I'm struggling with ASP .NET Validators JavaScript issue. Following function (part of framework generated code) tries to access validatioGroup attribute value using control.Field syntax. It works fine in IE, however in FF that value is always undefined. Consequently, validation always passes and my validation scenario is broken... Is there a way to get round it?

function IsValidationGroupMatch(control, validationGroup) {
if ((typeof(validationGroup) == "undefined") || (validationGroup == null)) {
return true;
}
var controlGroup = "";
if (typeof(control.validationGroup) == "string") {
controlGroup = control.validationGroup;
}
return (controlGroup == validationGroup);
}

View 1 Replies

Use Thread.sleep For No Reason And Explain It To Programmer?

Nov 10, 2010

While passing through code in our project I came across a web method that had this code at the end of it:

thread.sleep(6000);
return true;

Now, this was done so the jQuery ajax call from the client gets delayed and the ajax animation will show for a little bit longer. This is very wrong in my eyes. There shouldn't be this kind of connection between UI and server side. If he wants the animation to take longer he can use the setTimeOut function in the client side. Here is my problem: how can I explain to the programmer why this is so wrong? Not just because the client/server thing, but why ever call thread.sleep on a website?

View 6 Replies

Javascript - File Upload Not Working In Firefox

Mar 18, 2011

I have in my asp.net page

<input id="MyTextBox" runat="server" type="text" name="T1" size="20"/>
<asp:Button ID="UploadFileButton" runat="server" Text="Upload" />
<input id="FileUpload" runat="server" type="file" style="height: 22px; visibility:hidden;" />

linked to js script:

$("#UploadFileButton").live("click", function(event) {
event.preventDefault();
$("#FileUpload").click();
});
$(function() {
$('#FileUpload').change(function() {
$("#MyTextBox").val($(this).val());
});
});

this means when the user click UploadFileButton ,the chose file select popup shows.After the user chose a file the MyTextBox=Selct file path.

My problem is that my script works in Chrome but not in firefox.

View 3 Replies

Javascript Code Not Working In Mozilla And Firefox

May 27, 2010

This is my code for making textbox accept number only.

<asp:TextBox ID="txtRotationNo" runat="server" onkeydown="return NumberOnly();" CssClass="textbox"></asp:TextBox>
function NumberOnly () {
if(!(event.keyCode>=48 && event.keyCode<=57) && event.keyCode!=8) {
event.returnValue=null;
}
}

This code is working in Chrome and Opera, but not in firefox.

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved