473,781 Members | 2,718 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Executing code within a hyperlink

I am writing a photo gallery and suppose 8 photos are displayed. When the
user clicks on a button under the picture, I want it to add that picture
name to a "favorites" list within the session data, but NOT leave the page
the user is on. How could I do this?

thanks
Jul 17 '05 #1
3 2128
eric rudolph wrote:
I am writing a photo gallery and suppose 8 photos are displayed. When the
user clicks on a button under the picture, I want it to add that picture
name to a "favorites" list within the session data, but NOT leave the page
the user is on. How could I do this?


You could put an invisible IFrame on the page. The link targets the
IFrame, which gets your server to add it to the session, without the
user's browser navigating away from the page.

Cheers,
Nicholas Sherlock
Jul 17 '05 #2
Q: How can I process a link/form without allowing the page to refresh
or reload?
A:
1. Using PHP alone:
Send a header status with 204
2. IFRAME hack:
POST or link the request to the invisible IFRAME. Need to name the
IFRAME and use it for "target"ing .
3. javascript:
Use XMLHttpRequest object and preferably with AJAX technique.

Caveats:
(1) Status 204 is not supported in older browsers
(2) is kind of dirty hack that breaks browser's back button
(3) totally breaks accessibility criteria

Refer:
http://www.sitepoint.com/print/no-refresh-links
http://ppewww.ph.gla.ac.uk/~flavell/...4/results.html
http://jibbering.com/2002/4/httprequest.html
http://en.wikipedia.org/wiki/AJAX
++++
@todo Better question. Someone may help.

Jul 17 '05 #3
Q: How can I process a link/form without allowing the page to refresh
or reload?
A:
1. Using PHP alone:
Send a HTTP header status with 204
2. IFRAME hack:
POST or link the request to the invisible IFRAME. Need to name the
IFRAME and use it for "target"ing .
3. javascript:
Use XMLHttpRequest object and preferably with AJAX technique.

Caveats:
(1) breaks usability (especially without JavaScript alert) as it is de
facto to expect results after clicking the link or submitting the form.
Also, HTTP Status 204 is not supported in few older browsers.
(2) is kind of dirty hack that breaks browser's back button
(3) totally breaks accessibility criteria

Refer:
http://www.sitepoint.com/print/no-refresh-links
http://ppewww.ph.gla.ac.uk/~flavell/www/status204/
http://www.faqs.org/rfcs/rfc2616.html
http://www.php.net/header
http://jibbering.com/2002/4/httprequest.html
http://en.wikipedia.org/wiki/AJAX
++++
@revision 1 Initial
@revision 2 Reworded for clarity. More links
@todo Better question. Someone may help.

Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
15392
by: ian.irlandez | last post by:
Hey all, I'm trying to execute a bat file on the server in javascript. The javascript sits on the server as well. I'm currently using: document.location.href='testme.bat'; However the only thing it does is just opens up the bat file and shows my bat code in the browser. How can I execute the batch file instead of opening it and viewing it in the browser?
4
3124
by: Guadala Harry | last post by:
Suppose I have a hyperlink that, when clicked, executes a JavaScript function on the client. Separately I have a button that, when clicked, causes a post back and executes a server-side function, as in the following: <a id="HyperLink5" href="javascript:DoSomethingInClient()">Do Something</a> <asp:Button id="btnSaveChanges" EnableViewState="true" CommandName="SaveChanges" Visible="true" Width="115" runat="server" Text="Save...
7
1603
by: G. Dean Blake | last post by:
I have a hyperlink on my aspx page added at dev time. Is there a way to execute it from code? Thanks, G
6
5516
by: Paolo Pignatelli | last post by:
I have an aspx code behind page that goes something like this in the HTML view: <asp:HyperLink id=HyperLink1 runat="server" NavigateUrl='<%#"mailto:" &amp; DataBinder.Eval(Container.DataItem,"StoreEmail") &amp; "&amp;Subject=" &amp; DataBinder.Eval(Container.DataItem,"ProductName") ....
9
6466
by: Roy | last post by:
Hey all, On my html page I have a datagrid with the column: <boundColumn datafield="xyz" visible = false> </boundColumn> In my code behind, within item data bound event, I dynamically set the column text like so: e.item.cells(10).text = mystring.trim
3
3876
by: gary | last post by:
Hi, I am trying to reference an anchor in a user control with a url. This worked in 1.1 but no longer works in 2.0. The ascx control is located in a "/include" folder If you have a hyperlink control and you assign the navigateurl property = "../#anchor" whereby you want to add this # reference to the current url the url ends up with the #anchor twice.
2
3551
by: mikepolitowski | last post by:
Hi folks, I am have been trying to solve this problem for quite some time now and would appreciate any advice. I have been trying to call a code-behind function that is defined in my aspx.cs from within a DataList <ItemTemplate> block using the <%# %> syntax. I would not have written here if I had not spent over 6 hours trying to find a solution to this problem again any advice is greatly appreciated. I have included a code snippet...
1
2364
by: daniellee2006 | last post by:
I am creating a basic website to store people profiles and within this website i have a page that creates a table dependent on the number of records in mysql written in PHP within these tables they show images i need these images to hyperlink to other HTML pages... Note these tables are written within the <?PHParea of the full Script
2
3241
by: ismailc | last post by:
Hi, I need help please. I have a page with a stylesheet that is read from an aspx form. On the form I have an hyperlink object - which iIwant the Targeturl to open within the current frame where the hyperlink object is in. I read that i need to set it in my target="frame name" but i don't know what the current frame name is. or any other idea on how i can open the hyperlink's Targeturl within the current frame.
0
9639
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9474
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10143
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10076
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9939
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8964
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7486
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6729
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
3
2870
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.