|
There must be something else wrong. Buttons with javascript actions work just fine in forms.
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
You are missing a quuote in your onclick there.
Javascript definitely works on form controls so you're doing something else wrong.
|
|
|
|
|
and i don't want to put the javascipt in the same file with html , cos i have many many functions
|
|
|
|
|
In your html file, you can always write
<script type="text/javascript" src="myurl/myscript.js"></script> That keeps your script in a separate file for ease of maintenance and reuse.
Peter
Software rusts. Simon Stephenson, ca 1994.
|
|
|
|
|
Hi ,
I have a jquery sticky notification in .aspx main page where it shows notification of expiry date and all based on userid now my requirement is to place a hyperlink inside this notification so that when user cliks it navigates to a ssrs report page.How i can place a hyperlink inside a jquery notification.The notification method which i used is from this following website for your reference:
http://thrivingkings.com/sticky/.Any One Please Help
Ragesh.
|
|
|
|
|
Just add an href tag. Have you tried that? What exactly is the problem?
There are only 10 types of people in the world, those who understand binary and those who don't.
|
|
|
|
|
I have been going nuts trying to figure out how to get a dynamically generated web page to call a javascript function.
It all started with Neeraj Saluja's nifty HTML bar charts.
I have a web page which calls a CGI perl script to generate a new page.
On that page is a button which calls the barchart() function.
The barchart() function in turn generates a Content string, which is then written to a new window, displaying the chart.
I'd like to have an active link in the chart, which when clicked will call a function for displaying additional information about the chart element being clicked.
If you've worked with those bar charts, and can help me figure out a way to define a function to be called when clicking on a link in the chart, I'd love to hear about it.
the CGI script generates a complete page, with its own ... sections. A function defined there generates the bar chart page, which needs its own section for defining the function I want to call by clicking in the chart, but that has to be embedded in the string already being written by CGI.
It's too ghastly for words.
|
|
|
|
|
If I'm understanding you correctly, you could simply use an XmlHttpRequest to AJAX-load the generated page, then pluck out the chart using jQuery or something similar to stick it in your page.
Just a suggestion - I may be missing your problem entirely.
EDIT: Read over your question a few more times, realized I missed the point.
If these are really separate pages, then the only way to communicate between them without a refresh would be for the "show more info" page to use continual AJAX checks to a third file (on the server) that would be written to by the chart click (again, using AJAX) to notify the other page of the click. It's probably easier to bite the bullet and go with a refresh and regeneration of the info page on a chart click. Is that not an option?
Sorry for my first response, it was very stupid.
|
|
|
|
|
I have a web site showing some data. It is constructed of:
- A web app, showing data.(ASP.Net app, but I don't use server side features in showing data; It's pure HTML and JavaScript)
- A Service providing data in Json format.(WCF)
the client requests data and receives and shows them.
Now I want to change the process in order to works in push base strategy.
I googled and I found out that that Comet is a good choice, but I don't found practical samples in my case.
Some samples had client with php (server-side) and so on.
Now I want some hints on using comet in a way that client is pure JavaScript and HTML and server is WCF (server pushes Json to JavaScript )
Best wishes
|
|
|
|
|
The following code works as intended when a page is loaded with the defined elements, but does not if it is to be called on a MVC partial view rendering. I understand why it doesn’t is because the page has already loaded but the elements this code acts on has not been loaded.
I have tried referencing the source of the code in partial view .ascx file and have also tried loading the code within script tags: these do not work.
Any help on how I can get this to work on a partial view/page update would be appreciated.
Sliding.js
$(document).ready(function () {
$('.itemHeader').click(function () {
var priorSelectedParent = $('.itemHeaderSelected').parent().attr('id');
$('#' + priorSelectedParent + ' .hideableItem').slideUp('fast');
$('#' + priorSelectedParent + ' .itemHeaderSelected').addClass('itemHeader');
$('#' + priorSelectedParent + ' .itemHeader').removeClass('itemHeaderSelected');
var headerParent = $(this).parent().attr('id');
$('#' + headerParent + ' .hideableItem').slideDown('slow');
$('#' + headerParent + ' .itemHeader').addClass('itemHeaderSelected cornersRoundSmall');
$('#' + headerParent + ' .itemHeaderSelected').removeClass('itemHeader');
})
});
$(document).ready(function () {
$('.hideableItem').hide();
setTimeout(function () {
$('.openingHeader').trigger('click');
}, 10);
});
Thank you,
Ken
|
|
|
|
|
Eureka! While I was hoping for a JavaScript answer to completely solve this problem (and would still appreciate one if possible) I did find a solution and wanted to share it so that others may benefit.
There were two issues in this problem: attaching click events to the itemHeader class elements and getting the hideableItem class elements to hide after the partial page update. The following is what had to be changed to correct the issues.
• I had to do away with $(document).ready event statements wrapping the two functions and name them.
• Use the on() method to attach a handler to the click event.
• Within the page calling the partial update I had to modify the Ajax.ActionLink method by adding an additional property, OnSuccess, to the AjaxOptions list. OnSuccess calls the javascript function hidingItems when the partial page update is successfully completed.
Here is the code with the corrections.
Sliding.js
$(document).on('click', '.itemHeader', showItem);
function showItem() {
var priorSelectedParent = $('.itemHeaderSelected').parent().attr('id');
$('#' + priorSelectedParent + ' .hideableItem').slideUp('slow');
$('#' + priorSelectedParent + ' .itemHeaderSelected').addClass('itemHeader');
$('#' + priorSelectedParent + ' .itemHeader').removeClass('itemHeaderSelected');
var headerParent = $(this).parent().attr('id');
$('#' + headerParent + ' .hideableItem').slideDown('slow');
$('#' + headerParent + ' .itemHeader').addClass('itemHeaderSelected cornersRoundSmall');
$('#' + headerParent + ' .itemHeaderSelected').removeClass('itemHeader');
}
function hidingItems() {
$('.hideableItem').hide();
setTimeout(function () {
$('.openingHeader').trigger('click');
}, 10);
}
Index.aspx
<li class="selectionItem"><%= Ajax.ActionLink("Background","Background", new AjaxOptions{UpdateTargetId="columnContent", OnSuccess="hidingItems"}) %></li>
Thank you to all of you who took your time looking into this problem for me.
Ken
|
|
|
|
|
guys;
As we know input type file uses a file dialog to let the user select the file to be uploaded. In most browsers the js code execution stops until the dialog is closed, but not in Safary and Opera.
I am wondering if there is a way to detect the dialog closing.
Help people,so poeple can help you.
|
|
|
|
|
There is two even you should take a look
1. onchange
2. onselect
also read the link[^] for more info
|
|
|
|
|
Dear guys,
I am just trying to inject some javascript code to a someone's web. I will then try to analyse the image obtained by getElementById.
However the image I got is every time different from what I see as I believe the image is dynamic, once I use getElementById, request is sent to server so getting new images.
I am a newbie to JS, can you please suggest how I can obtain the same image. say without requesting again, or any workaround like screencapture.
Thanks!
|
|
|
|
|
Sir;
I don't think that getElementById() function requests the server. It searches the document for the given id and returns the specific element.
But, if you sent me your code, i can see it for you.
Help people,so poeple can help you.
|
|
|
|
|
Thanks for your reply!
Well I tried to inject the JS code to a web, all things worked fine except the dynamic image.
Some of the codes are:
<pre lang="cs">
var image = document.getElementsByTagName('img')[9];
alert(image.src);
var req =new XMLHttpRequest();
req.open(&quot;GET&quot;, image.src, true);
req.onreadystatechange = function() {
if (req.readyState == 4) {
if (req.status == 200) {
var data =req.responseText;
var data_array = [];
for (var i = 0; i &lt; data.length; i++)
{
data_array.push(data[i].charCodeAt(0) &amp; 0xff);
}
for (var i = 0; i &lt; 10; i++)
{
var o = document.body;
var div = document.createElement(&quot;div&quot;);
div.innerHTML = data_array[i];
o.appendChild(div);
}
}
}
};
</pre></pre>
|
|
|
|
|
Look, Sir;
The response come from the server cannot be fetch by XMLHttpRequest because its not XML based.
instead you can try this
var image = document.getElementsByTagName('img')[9];
alert(image.src);
var o = document.body;
var copy = document.createElement("img");
copy.src = image.src;
o.appendChild(copy);
Sir;
An image element presents an inner frame within the document that requests the server with its source (src) and fetch a response of type image.
Help people,so poeple can help you.
|
|
|
|
|
Hi Sir, Thanks for your reply!
I will try to see whether both images are the same.
Btw, what if I wanna analyse the pixels within that image.
var imageObject = document.getElementsByTagName('img')[9];
Does this imageObject contain any data in memory, or just a reference?
Thx again!
|
|
|
|
|
sir;
I am sorry, return to your first code and call XMLHttpRequest.send() at the end to send the request to the server. Just like: req.send(null)
Help people,so poeple can help you.
|
|
|
|
|
Ali Al Omairi(Abu AlHassan) wrote: The response come from the server cannot be fetch by XMLHttpRequest because its not XML based.
PLEASE tell me you don't think that XmlHttpRequest can only deal in Xml!!!!
C# has already designed away most of the tedium of C++.
|
|
|
|
|
Actually, I wasn't aware about that. Anyway, people learn from their mistakes, right?
Help people,so poeple can help you.
|
|
|
|
|
Fair enough - we all learn things we didn't know (I won't embarrass myself by pointing out the "beginners mistake" I made a few days ago!)
There are two useful fields on the response you get back from an Ajax call - responseXml (which you've already discovered), and responseText. Now if you are indeed sending Xml back, then responseXml will be correctly filled in, and responseText will contain exactly the same.
However, if in your server side code, you do a simple Response.Write("Hello World"), then IIRC responseText will contain this, responseXml will be empty (you'll need to check that last empty point - been a while!)
What this means is that you can write ANYTHING you want back and pick it up out of responseText - one neat trick I've employed in the past is to make DataGrids render as part of an ajax call, write the Html back on the response, pull it out of the responseText and slap in into a div's innerHtml property.....
C# has already designed away most of the tedium of C++.
|
|
|
|
|
you are over my head, ya man.
100
Help people,so poeple can help you.
|
|
|
|
|
Request never goes to server.
|
|
|
|
|
A save function to be used for saving crystal report without opening.
can u help on this?
|
|
|
|