Posts Tagged 'Javascript&'

Nov

26

How to redirect URL with Javascript

Posted by admin under internet, technology - No Comments

——————————————1.—————————————-
<script language=”javascript” type=”text/javascript”>
window.location.href=”login.php?backurl=”+window.location.href;
</script>
——————————————2.—————————————-
<script language=”javascript”>
alert(”back”);
window.history.back(-1);
</script>
——————————————3.—————————————-
<script language=”javascript”>
window.navigate(”tmtbox.php”);
</script>
——————————————4.—————————————-
<script language=”JavaScript”>
self.location=”tmtbox.htm”;
</script>
——————————————5.—————————————
<script language=”javascript”>
alert(”Access Violation”);
top.location=”error.php”;
</script>

Jul

9

Yet Another Image Replacement Method

Posted by admin under internet, technology - 1 Comment

Semantic CSS Image Replacement

Yes, “YAIRM” (“Yet Another Image Replacement Method”) is a crappy acronym. Anyhow….

There have been several image replacement suggestions made over the past 5 years. Semantically, some just don’t make sense. Of course, the accessibility of your image replacement method and the semantic “correctness” has to do with how you code your HTML.

Pros

  • This method works for both in-line and block style elements.
  • Accessible to screen readers and non-image/non-screen media.
  • Does not add extra elements only for styling (no extra span).
  • Works cross browser

Cons

  • Using images for text does not allow for text resizing (like all IR methods).
  • Does not handle “images off/CSS on” scenario; but neither do most layouts with background images, such as the sidebar on this blog.

When I need to replace a header or some other text with an image, I simply give the element my image replacement class (<h1 class="imgreplacement">), and declare the background image, height and width I want to use either by providing an ID and defining the background image in the #id selector, or by targeting the element through specific/unique cascade. I place all of my image replacement css in a media=”screen”. Even though the media attribute is not heeded by all browsers, it is heeded by devices that are not screens. If your user than prints your webpage, the text that was replaced by an image in the browser will print as it semantically should.
button.imgreplacement { display:-moz-inline-box; display:inline-block; background:transparent none 0 0 no-repeat; text-indent:-3000px; font:0/0 Arial; overflow:hidden; color:rgba(255,255,255,0); vertical-align:bottom; background-image:url(http://www.evotech.net/articles/images/redx.gif); width: 18px; height: 18px; border:none; cursor: pointer, hand; }
Continue Reading »

May

5

About the drag and drop

Posted by admin under internet, technology, web2.0 - No Comments

Visual development environments typically let you manipulate objects in an application by selecting them with a mouse and moving them around the screen. Drag and drop lets you select an object, such as an item in a List control, or a Flex control such as an Image control, and then drag it over another component to add it to that component. You can add support for drag and drop to all Flex components. Flex also includes built-in support for the drag-and-drop operation for certain controls such as List, Tr e e, and DataGrid, that automate much of the processing required to support drag and drop.

The drag-and-drop operation has three main stages: initiation, dragging, and dropping:

Initiation A user initiates a drag-and-drop operation by using the mouse to select a Flex component, or an item in a Flex component, and then moving the component or item while holding down the mouse button. For example, a user selects an item in a List control with the mouse and, while holding down the mouse button, moves the mouse several pixels. The selected component, the List control in this example, is the drag initiator.

Dragging While still holding down the mouse button, the user moves the mouse around the Flex application. Flex displays an image during the drag, called the drag proxy. A drag source object (an object of type DragSource) contains the data being dragged.

Dropping When the user moves the drag proxy over another Flex component, that component becomes a possible drop target. The drop target inspects the drag source object to determine whether the data is in a format that the target accepts and, if so, allows the user drop the data onto it. If the drop target determines that the data is not in an acceptable format, the drop target disallows the drop.

A drag-and-drop operation either copies or moves data from the drag initiator to the drop target. Upon a successful drop, Flex adds the data to the drop target and, optionally, deletes it from the drag initiator in the case of a move.

The following figure shows one List control functioning as the drag initiator and a second List control functioning as the drop target. In this example, you use drag and drop to move the ’Television’ list item from the drag initiator to the drop target:

A single Flex component can function as both the drag initiator and the drop target. This lets you move the data within the component. The following example shows a List control functioning as both the drag initiator and the drop target:

Nov

16

Powering Javascript UI with CSS

Posted by admin under resource, technology - No Comments

If you have been doing any Javscript coding during the current Javascript renaissance, you will have noticed that a lot of the user interface functionality you build is hiding and showing things.

After a while of this you might find yourself coding up toggle functions, which find elements and toggle their visibility. togglePair, toggleVisibilityById, there are lots of these types of functions in javascript apps today.

I’ve been trying out a different way of dealing with the need to change the UI based on user inputs or asynchronous data events: CSS.

With CSS, you can use the DOM as a data model and then use declarative rules to establish the display. It’s cleaner, because you limit your javascript code to changing the DOM’s data instead of it’s UI, and then you use the extensive abilities of CSS to handle the visual representation of that data.

Here’s an example. A common thing to do with javascript seems to be expanding out a form to fill out. Livejournal does this with their login form, or 37Signal’s tadalist uses this when you want to add an item to your todo list.

here’s the just javascript way to do this:

<div>
  <span onClick='document.getElementById("form1").style.display="block";'>click me to add a comment</span>
</div>
 ...
<form id='form1'>
<textarea>add your comment</textarea>
</form>

But here’s the CSS + Javascript way to do it.
CSS Rules

form#addComment {

display:none;

}

form#addComment.editing {
  display:block;
}

Javascript + HTML

<div>
  <span onClick='document.getElementById("addComment").setAttribute("class","editing");'>click me to show form</span>
</div>
 ...
<form id='addComment'>
<textarea>fill in some data here</textarea>
</form>

This can prove really advantageous when you are radically changing the visual presentation of the page. Instead of finding and changing the style of tons of elements by id, you can change 1 element’s class and then use the inheritance of CSS to style all the sub-elements.