Question

Changing Image Source From Link References

Asked by: WavyGravy

Is it possible to have the reference from a link determine what the source of an image will be?

I currently have a page with 30 links.  The HTML follows this methodology:

<li><a href="#0001">Link 1</a></li>
<li><a href="#0002">Link 2</a></li>
...
<li><a href="#0030">Link 30</a></li>

With that, I'm wanting to change the source of the image.  For instance, if someone clicks on Link 1, I want the image URL to be ../image0001.jpg.  Link 2 being ../image0002.jpg etc.

Any ideas as to how I would do this with javascript?

Thanks in advance.

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-05-04 at 03:23:26ID24377461
Tags

javascript

,

iphone

Topics

JavaScript

,

iPhone

Participating Experts
1
Points
500
Comments
8

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. Methodologies?
    I just started using C#... actually I just started developing apps. I have worked with PHP, ColdFusion, JavaScript, Flash, HTML, CSS... So I am a web developer turned programmer... jk I don't know my head from my butt about programming. Anyway like I said I just started usin...
  2. href change with javascript
    I though I didnt have any problem, till I tested my page on Internet Explorer :P I made a simple page with web gallery. Since I have to work with a single html document, the only way was with JavaScript. The idea is to one picture un underneath her two links: previous and ne...
  3. Backup Methodology
    I am seeking some 'independent' reviews of various backup methodologies. People's experience, thoughts and references to reviews would be appreciated. Configuation should be suitable SBS 2000 (soon to be SBS 2003) separate SQL server and a file server.
  4. change the li backgroun image
    Hello Experts, I have a dynamic menu in the left navigation which gets added based on the user selection, it is working fine however, i want to change the <LI> background image to something like [-] (this should be hyperlink) at present I have something like this $('...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: mkosbiePosted on 2009-05-04 at 03:32:07ID: 24293757

Why do you want to make the links this way?  Why not just put the actual full image path in the links?

Anyways, to answer the question, attach a click handler to all the <a> tags on the page, then in the function that processes it, manually handle the redirect.  Something like this maybe.

<html>
<head>
<script type="text/javascript">
window.onload = function() {
    var as = document.getElementsByTagName("A");
    for(i=0;i<as.length;i++) as[i].onclick = processClick;
};
 
function processClick(e) {
    if(!e) e=window.event;
    var t = e.target ? e.target : e.srcElement;
 
    var redirect = "../image" + t.href.substring(1,4) + ".jpg";
    document.location.replace(redirect);
}
</script>
</head>
<body>
<a href="#0001">Link 1</a>
<a href="#0002">Link 2</a>
</body>
</html>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:

Select allOpen in new window

 

by: mkosbiePosted on 2009-05-04 at 03:36:47ID: 24293777

Sorry, that won't work reliably cross-browser.  Try with this correction.

<html>
<head>
<script type="text/javascript">
window.onload = function() {
    var as = document.getElementsByTagName("A");
    for(i=0;i<as.length;i++) as[i].onclick = processClick;
};
 
function processClick(e) {
    if(!e) e=window.event;
    var t = e.target ? e.target : e.srcElement;
 
    var redirect = "../image" + t.href.split("#")[1] + ".jpg";
    document.location.replace(redirect);
}
</script>
</head>
<body>
<a href="#0001">Link 1</a>
<a href="#0002">Link 2</a>
</body>
</html>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:

Select allOpen in new window

 

by: WavyGravyPosted on 2009-05-04 at 03:42:28ID: 24293802

Things have to be this way because it's a limitation of the iUI library for iPhone web application development.  To further explain things I am developing a web application that displays the feed from traffic cameras.  Because there are over 100 of them, I figured it would be a lot easier have one page (or div tag in this case) handle the camera view and other information, and that information could come from the link bringing it there.

I've attached a code snippet to give you the gist of things.  Let me know if it helps, and if you'd recommend a different solution because of it.

Thanks for the help thus far though.  :-)

<!-- Main Menu -->
    <ul id="mainMenu" title="Main Menu" selected="true">
		<li><a href="#cameras">Traffic Cameras</a></li>
		<li><a href="#about">About</a></li>
    </ul>
	
	<!-- Traffic Cameras-->
	<ul id="cameras" title="Traffic Cameras">
		<li><a href="#i64">I-64</a></li>
		<li><a href="#i65">I-65</a></li>
		<li><a href="#i71">I-71</a></li>
		<li><a href="#i264">I-264</a></li>
		<li><a href="#i265">I-265</a></li>
		<li><a href="#downtown">Downtown</a></li>
	</ul>
	<!-- I-64 -->
	<ul id="i64" title="I-64">
		<li class="group">High Traffic Areas</li>
		<li><a href="#i64_22nd">22nd St.</a></li>
		<li><a href="#i64_grinstead">Grinstead Dr.</a></li>
		<li><a href="#i64_ofr">Oxmoor Farm Rd.</a></li>
		<li class="group">Intersections</li>
		<li><a href="#i64_i264">I-264</a></li>
		<li><a href="#i64_i265">I-265</a></li>
	</ul>
	<div id="i64_22nd" title="22nd Street" class="panel">
		<img src="http://trimarc.org/images/snapshots/CCTV028.jpg" width="300" height="225" align="center"><br /><br />
		<h2>More Information</h2>
		<fieldset>
			<div class="row">
				<label>Mile Marker: 3.2</label>
			</div>
			<div class="row">
				<label>CCTV No.: 028</label>
			</div>
		</fieldset>
	</div>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:

Select allOpen in new window

 

by: mkosbiePosted on 2009-05-04 at 03:59:16ID: 24293880

I'm not entirely clear on what the navigation scheme is here.  You want the user to click a link, and be redirected to a new page?  Or you want them to click a link and have it update the current page accordingly?  Based on the code you provided, I think you mean the latter.  You will run into a small problem of differentiating between links that should update the image and those that don't.  I would just drop a class onto the ones that do.

Same base code as before, but here's one with some added in stuff to update the local page based on the href value.  Note that you MUST return false at the end of the handler function to avoid redirecting the page.

<html>
<head>
<script type="text/javascript">
window.onload = function() {
    var as = document.getElementsByTagName("A");
    for(i=0;i<as.length;i++) if(as[i].className=="imgUpdater") as[i].onclick = processClick;
};
 
function processClick(e) {
    if(!e) e=window.event;
    var t = e.target ? e.target : e.srcElement;
 
    var imgToUpdate = document.getElementById("imgToUpdate");
    imgToUpdate.src = "../image" + t.href.split("#")[1] + ".jpg";
 
    return false;
}
</script>
</head>
<body>
<img src="myimg.jpg" id="imgToUpdate" />
<br>
<a href="#0001" class="imgUpdater">Link 1</a>
<a href="#0002" class="imgUpdater">Link 2</a>
<br>
<a href="http://www.google.com">Google</a>
</body>
</html>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:

Select allOpen in new window

 

by: WavyGravyPosted on 2009-05-04 at 04:22:20ID: 24293983

Uh oh, I think I've made this more complicated than it needed to be.  With that said, I'm EXTREMELY appreciative for your help so far.  To clarify, here's why everything is structured the way it is.

The part of the iPhone UI that I'm emulating is when it generates lists and and a selection is made, it "slides" to the next set of options.  You can see the app I'm working on at http://mrgravy.com/iphone.  Firefox should emulate it to an extent, at least enough to give you an idea.

With that said, the old version of this app had each camera with it's own "panel," or div element.  For the sake of better coding, I want to use one div element, called "cameraView"  This cameraView panel contains the most current image from the webcam, and it's mile marker location.  I figured that javascript would allow me to write a function that can alter the image URL of the image and text label with the mile marker info, depending on which camera in the list is clicked.  It's just I have no clue how to do it for the time being...

 

by: WavyGravyPosted on 2009-05-04 at 04:23:54ID: 24293987

...so in other words, ALL camera links must point to "#cameraView"  I've tried <a href="#cameraView" onClick='document.getElementById("imgToUpdate").src="http://trimarc.org/images/snapshots/CCTV020.jpg"'> to no avail though...

 

by: WavyGravyPosted on 2009-05-04 at 04:41:03ID: 24294077

Mother of God.  I'm starting to lose my mind now.  ANY help here would save the day.

What I've attached below is the function I created to change the URL of the image that will display the webcam.  In theory it makes sense.  However, when testing it in Firefox and on the iPhone, nothing happens when the camera link is clicked.  However, in IE8, it works fine.  That's besides the point though, because it needs to work on the iPhone's Safari.

In order to get the iPhone UI goodness, I'm having to use the iUI library, which has it's own javascript as well.  It's attached as well, and it's making me think that there's a conflict somewhere.  A conflict that one of you javascript guru's could pick up on in less than a few minutes.

So please, any help to get me going again will be GREATLY appreciated!

Thanks in advance!



<!-- Javascript Function -->
<script type="text/javascript">
	function theCamera(wci, mm)
	{
		var trafficCamera;
		var mileMarker;
		trafficCamera = document.getElementById("imgToUpdate");
		trafficCamera.src = wci;
		mileMarker = mm;
	}
</script>
 
<!-- Traffic Camera Link -->
<li><a href="#displayCamera" onclick="theCamera('http://trimarc.org/images/snapshots/CCTV020.jpg', 'nothingYet')">Camera 20</a></a></li>
 
<!-- Element showing the camera -->
<div id="#cameraView" title="" class="panel">
	<img id="imgToUpdate" src="" width="300" height="225" align="center"><br /><br />
		<h2>More Information</h2>
		<fieldset>
			<div class="row">
				<label>Mile Marker: 18.6</label>
			</div>
			<div class="row">
				<label>CCTV No.: 045</label>
			</div>
	</fieldset>
</div>
 
<!-- Evil iUI Javascript -->
/*
   Copyright (c) 2007-9, iUI Project Members
   See LICENSE.txt for licensing terms
 */
 
 
(function() {
 
var slideSpeed = 20;
var slideInterval = 0;
 
var currentPage = null;
var currentDialog = null;
var currentWidth = 0;
var currentHash = location.hash;
var hashPrefix = "#_";
var pageHistory = [];
var newPageCount = 0;
var checkTimer;
var hasOrientationEvent = false;
var portraitVal = "portrait";
var landscapeVal = "landscape";
 
// *************************************************************************************************
 
window.iui =
{
    showPage: function(page, backwards)
    {
        if (page)
        {
            if (currentDialog)
            {
                currentDialog.removeAttribute("selected");
                currentDialog = null;
            }
 
            if (hasClass(page, "dialog"))
                showDialog(page);
            else
            {
                var fromPage = currentPage;
                currentPage = page;
 
                if (fromPage)
                    setTimeout(slidePages, 0, fromPage, page, backwards);
                else
                    updatePage(page, fromPage);
            }
        }
    },
 
    showPageById: function(pageId)
    {
        var page = $(pageId);
        if (page)
        {
            var index = pageHistory.indexOf(pageId);
            var backwards = index != -1;
            if (backwards)
                pageHistory.splice(index, pageHistory.length);
 
            iui.showPage(page, backwards);
        }
    },
 
    showPageByHref: function(href, args, method, replace, cb)
    {
        var req = new XMLHttpRequest();
        req.onerror = function()
        {
            if (cb)
                cb(false);
        };
        
        req.onreadystatechange = function()
        {
            if (req.readyState == 4)
            {
                if (replace)
                    replaceElementWithSource(replace, req.responseText);
                else
                {
                    var frag = document.createElement("div");
                    frag.innerHTML = req.responseText;
                    iui.insertPages(frag.childNodes);
                }
                if (cb)
                    setTimeout(cb, 1000, true);
            }
        };
 
        if (args)
        {
            req.open(method || "GET", href, true);
            req.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
            req.setRequestHeader("Content-Length", args.length);
            req.send(args.join("&"));
        }
        else
        {
            req.open(method || "GET", href, true);
            req.send(null);
        }
    },
    
    insertPages: function(nodes)
    {
        var targetPage;
        for (var i = 0; i < nodes.length; ++i)
        {
            var child = nodes[i];
            if (child.nodeType == 1)
            {
                if (!child.id)
                    child.id = "__" + (++newPageCount) + "__";
 
                var clone = $(child.id);
                if (clone)
                    clone.parentNode.replaceChild(child, clone);
                else
                    document.body.appendChild(child);
 
                if (child.getAttribute("selected") == "true" || !targetPage)
                    targetPage = child;
                
                --i;
            }
        }
 
        if (targetPage)
            iui.showPage(targetPage);    
    },
 
    getSelectedPage: function()
    {
        for (var child = document.body.firstChild; child; child = child.nextSibling)
        {
            if (child.nodeType == 1 && child.getAttribute("selected") == "true")
                return child;
        }    
    },
    isNativeUrl: function(href)
    {
        for(var i = 0; i < iui.nativeUrlPatterns.length; i++)
        {
            if(href.match(iui.nativeUrlPatterns[i])) return true;
        }
        return false;
    },
    nativeUrlPatterns: [
        new RegExp("^http:\/\/maps.google.com\/maps\?"),
        new RegExp("^mailto:"),
        new RegExp("^tel:"),
        new RegExp("^http:\/\/www.youtube.com\/watch\\?v="),
        new RegExp("^http:\/\/www.youtube.com\/v\/")
    ]
};
 
// *************************************************************************************************
 
addEventListener("load", function(event)
{
    var page = iui.getSelectedPage();
    if (page)
        iui.showPage(page);
 
    setTimeout(preloadImages, 0);
    setTimeout(checkOrientAndLocation, 0);
    checkTimer = setInterval(checkOrientAndLocation, 300);
}, false);
 
addEventListener("unload", function(event)
{
	return;
}, false);
    
addEventListener("click", function(event)
{
    var link = findParent(event.target, "a");
    if (link)
    {
        function unselect() { link.removeAttribute("selected"); }
        
        if (link.href && link.hash && link.hash != "#")
        {
            link.setAttribute("selected", "true");
            iui.showPage($(link.hash.substr(1)));
            setTimeout(unselect, 500);
        }
        else if (link == $("backButton"))
            history.back();
        else if (link.getAttribute("type") == "submit")
            submitForm(findParent(link, "form"));
        else if (link.getAttribute("type") == "cancel")
            cancelDialog(findParent(link, "form"));
        else if (link.target == "_replace")
        {
            link.setAttribute("selected", "progress");
            iui.showPageByHref(link.href, null, null, link, unselect);
        }
        else if (iui.isNativeUrl(link.href))
        {
            return;
        }
        else if (!link.target)
        {
            link.setAttribute("selected", "progress");
            iui.showPageByHref(link.href, null, null, null, unselect);
        }
        else
            return;
        
        event.preventDefault();        
    }
}, true);
 
addEventListener("click", function(event)
{
    var div = findParent(event.target, "div");
    if (div && hasClass(div, "toggle"))
    {
        div.setAttribute("toggled", div.getAttribute("toggled") != "true");
        event.preventDefault();        
    }
}, true);
 
function orientChangeHandler()
{
  var orientation=window.orientation;
  switch(orientation)
  {
    case 0:
        setOrientation(portraitVal);
        break;  
        
    case 90:
    case -90: 
        setOrientation(landscapeVal);
        break;
  }
}
 
if (typeof window.onorientationchange == "object")
{
    window.onorientationchange=orientChangeHandler;
    hasOrientationEvent = true;
    setTimeout(orientChangeHandler, 0);
}
 
function checkOrientAndLocation()
{
    if (!hasOrientationEvent)
    {
      if (window.innerWidth != currentWidth)
      {   
          currentWidth = window.innerWidth;
          var orient = currentWidth == 320 ? portraitVal : landscapeVal;
          setOrientation(orient);
      }
    }
 
    if (location.hash != currentHash)
    {
        var pageId = location.hash.substr(hashPrefix.length);
        iui.showPageById(pageId);
    }
}
 
function setOrientation(orient)
{
    document.body.setAttribute("orient", orient);
    setTimeout(scrollTo, 100, 0, 1);
}
 
function showDialog(page)
{
    currentDialog = page;
    page.setAttribute("selected", "true");
    
    if (hasClass(page, "dialog") && !page.target)
        showForm(page);
}
 
function showForm(form)
{
    form.onsubmit = function(event)
    {
        event.preventDefault();
        submitForm(form);
    };
    
    form.onclick = function(event)
    {
        if (event.target == form && hasClass(form, "dialog"))
            cancelDialog(form);
    };
}
 
function cancelDialog(form)
{
    form.removeAttribute("selected");
}
 
function updatePage(page, fromPage)
{
    if (!page.id)
        page.id = "__" + (++newPageCount) + "__";
 
    location.href = currentHash = hashPrefix + page.id;
    pageHistory.push(page.id);
 
    var pageTitle = $("pageTitle");
    if (page.title)
        pageTitle.innerHTML = page.title;
 
    if (page.localName.toLowerCase() == "form" && !page.target)
        showForm(page);
        
    var backButton = $("backButton");
    if (backButton)
    {
        var prevPage = $(pageHistory[pageHistory.length-2]);
        if (prevPage && !page.getAttribute("hideBackButton"))
        {
            backButton.style.display = "inline";
            backButton.innerHTML = prevPage.title ? prevPage.title : "Back";
        }
        else
            backButton.style.display = "none";
    }    
}
 
function slidePages(fromPage, toPage, backwards)
{        
    var axis = (backwards ? fromPage : toPage).getAttribute("axis");
    if (axis == "y")
        (backwards ? fromPage : toPage).style.top = "100%";
    else
        toPage.style.left = "100%";
 
    toPage.setAttribute("selected", "true");
    scrollTo(0, 1);
    clearInterval(checkTimer);
    
    var percent = 100;
    slide();
    var timer = setInterval(slide, slideInterval);
 
    function slide()
    {
        percent -= slideSpeed;
        if (percent <= 0)
        {
            percent = 0;
            if (!hasClass(toPage, "dialog"))
                fromPage.removeAttribute("selected");
            clearInterval(timer);
            checkTimer = setInterval(checkOrientAndLocation, 300);
            setTimeout(updatePage, 0, toPage, fromPage);
        }
    
        if (axis == "y")
        {
            backwards
                ? fromPage.style.top = (100-percent) + "%"
                : toPage.style.top = percent + "%";
        }
        else
        {
            fromPage.style.left = (backwards ? (100-percent) : (percent-100)) + "%"; 
            toPage.style.left = (backwards ? -percent : percent) + "%"; 
        }
    }
}
 
function preloadImages()
{
    var preloader = document.createElement("div");
    preloader.id = "preloader";
    document.body.appendChild(preloader);
}
 
function submitForm(form)
{
    iui.showPageByHref(form.action || "POST", encodeForm(form), form.method);
}
 
function encodeForm(form)
{
    function encode(inputs)
    {
        for (var i = 0; i < inputs.length; ++i)
        {
            if (inputs[i].name)
                args.push(inputs[i].name + "=" + escape(inputs[i].value));
        }
    }
 
    var args = [];
    encode(form.getElementsByTagName("input"));
    encode(form.getElementsByTagName("textarea"));
    encode(form.getElementsByTagName("select"));
    return args;    
}
 
function findParent(node, localName)
{
    while (node && (node.nodeType != 1 || node.localName.toLowerCase() != localName))
        node = node.parentNode;
    return node;
}
 
function hasClass(self, name)
{
    var re = new RegExp("(^|\\s)"+name+"($|\\s)");
    return re.exec(self.getAttribute("class")) != null;
}
 
function replaceElementWithSource(replace, source)
{
    var page = replace.parentNode;
    var parent = replace;
    while (page.parentNode != document.body)
    {
        page = page.parentNode;
        parent = parent.parentNode;
    }
 
    var frag = document.createElement(parent.localName);
    frag.innerHTML = source;
 
    page.removeChild(parent);
 
    while (frag.firstChild)
        page.appendChild(frag.firstChild);
}
 
function $(id) { return document.getElementById(id); }
function ddd() { console.log.apply(console, arguments); }
 
})();
 
<!-- More Evil Javascript -->
(function(){var _1=20;var _2=0;var _3=null;var _4=null;var _5=0;var _6=location.hash;var _7="#_";var _8=[];var _9=0;var _a;var _b=false;var _c="portrait";var _d="landscape";window.iui={showPage:function(_e,_f){if(_e){if(_4){_4.removeAttribute("selected");_4=null;}if(hasClass(_e,"dialog")){showDialog(_e);}else{var _10=_3;_3=_e;if(_10){setTimeout(slidePages,0,_10,_e,_f);}else{updatePage(_e,_10);}}}},showPageById:function(_11){var _12=$(_11);if(_12){var _13=_8.indexOf(_11);var _14=_13!=-1;if(_14){_8.splice(_13,_8.length);}iui.showPage(_12,_14);}},showPageByHref:function(_15,_16,_17,_18,cb){var req=new XMLHttpRequest();req.onerror=function(){if(cb){cb(false);}};req.onreadystatechange=function(){if(req.readyState==4){if(_18){replaceElementWithSource(_18,req.responseText);}else{var _1b=document.createElement("div");_1b.innerHTML=req.responseText;iui.insertPages(_1b.childNodes);}if(cb){setTimeout(cb,1000,true);}}};if(_16){req.open(_17||"GET",_15,true);req.setRequestHeader("Content-Type","application/x-www-form-urlencoded");req.setRequestHeader("Content-Length",_16.length);req.send(_16.join("&"));}else{req.open(_17||"GET",_15,true);req.send(null);}},insertPages:function(_1c){var _1d;for(var i=0;i<_1c.length;++i){var _1f=_1c[i];if(_1f.nodeType==1){if(!_1f.id){_1f.id="__"+(++_9)+"__";}var _20=$(_1f.id);if(_20){_20.parentNode.replaceChild(_1f,_20);}else{document.body.appendChild(_1f);}if(_1f.getAttribute("selected")=="true"||!_1d){_1d=_1f;}--i;}}if(_1d){iui.showPage(_1d);}},getSelectedPage:function(){for(var _21=document.body.firstChild;_21;_21=_21.nextSibling){if(_21.nodeType==1&&_21.getAttribute("selected")=="true"){return _21;}}},isNativeUrl:function(_22){for(var i=0;i<iui.nativeUrlPatterns.length;i++){if(_22.match(iui.nativeUrlPatterns[i])){return true;}}return false;},nativeUrlPatterns:[new RegExp("^http://maps.google.com/maps?"),new RegExp("^mailto:"),new RegExp("^tel:"),new RegExp("^http://www.youtube.com/watch\\?v="),new RegExp("^http://www.youtube.com/v/")]};addEventListener("load",function(_24){var _25=iui.getSelectedPage();if(_25){iui.showPage(_25);}setTimeout(preloadImages,0);setTimeout(checkOrientAndLocation,0);_a=setInterval(checkOrientAndLocation,300);},false);addEventListener("unload",function(_26){return;},false);addEventListener("click",function(_27){var _28=findParent(_27.target,"a");if(_28){function unselect(){_28.removeAttribute("selected");}if(_28.href&&_28.hash&&_28.hash!="#"){_28.setAttribute("selected","true");iui.showPage($(_28.hash.substr(1)));setTimeout(unselect,500);}else{if(_28==$("backButton")){history.back();}else{if(_28.getAttribute("type")=="submit"){submitForm(findParent(_28,"form"));}else{if(_28.getAttribute("type")=="cancel"){cancelDialog(findParent(_28,"form"));}else{if(_28.target=="_replace"){_28.setAttribute("selected","progress");iui.showPageByHref(_28.href,null,null,_28,unselect);}else{if(iui.isNativeUrl(_28.href)){return;}else{if(!_28.target){_28.setAttribute("selected","progress");iui.showPageByHref(_28.href,null,null,null,unselect);}else{return;}}}}}}}_27.preventDefault();}},true);addEventListener("click",function(_29){var div=findParent(_29.target,"div");if(div&&hasClass(div,"toggle")){div.setAttribute("toggled",div.getAttribute("toggled")!="true");_29.preventDefault();}},true);function orientChangeHandler(){var _2b=window.orientation;switch(_2b){case 0:setOrientation(_c);break;case 90:case -90:setOrientation(_d);break;}}if(typeof window.onorientationchange=="object"){window.onorientationchange=orientChangeHandler;_b=true;setTimeout(orientChangeHandler,0);}function checkOrientAndLocation(){if(!_b){if(window.innerWidth!=_5){_5=window.innerWidth;var _2c=_5==320?_c:_d;setOrientation(_2c);}}if(location.hash!=_6){var _2d=location.hash.substr(_7.length);iui.showPageById(_2d);}}function setOrientation(_2e){document.body.setAttribute("orient",_2e);setTimeout(scrollTo,100,0,1);}function showDialog(_2f){_4=_2f;_2f.setAttribute("selected","true");if(hasClass(_2f,"dialog")&&!_2f.target){showForm(_2f);}}function showForm(_30){_30.onsubmit=function(_31){_31.preventDefault();submitForm(_30);};_30.onclick=function(_32){if(_32.target==_30&&hasClass(_30,"dialog")){cancelDialog(_30);}};}function cancelDialog(_33){_33.removeAttribute("selected");}function updatePage(_34,_35){if(!_34.id){_34.id="__"+(++_9)+"__";}location.href=_6=_7+_34.id;_8.push(_34.id);var _36=$("pageTitle");if(_34.title){_36.innerHTML=_34.title;}if(_34.localName.toLowerCase()=="form"&&!_34.target){showForm(_34);}var _37=$("backButton");if(_37){var _38=$(_8[_8.length-2]);if(_38&&!_34.getAttribute("hideBackButton")){_37.style.display="inline";_37.innerHTML=_38.title?_38.title:"Back";}else{_37.style.display="none";}}}function slidePages(_39,_3a,_3b){var _3c=(_3b?_39:_3a).getAttribute("axis");if(_3c=="y"){(_3b?_39:_3a).style.top="100%";}else{_3a.style.left="100%";}_3a.setAttribute("selected","true");scrollTo(0,1);clearInterval(_a);var _3d=100;slide();var _3e=setInterval(slide,_2);function slide(){_3d-=_1;if(_3d<=0){_3d=0;if(!hasClass(_3a,"dialog")){_39.removeAttribute("selected");}clearInterval(_3e);_a=setInterval(checkOrientAndLocation,300);setTimeout(updatePage,0,_3a,_39);}if(_3c=="y"){_3b?_39.style.top=(100-_3d)+"%":_3a.style.top=_3d+"%";}else{_39.style.left=(_3b?(100-_3d):(_3d-100))+"%";_3a.style.left=(_3b?-_3d:_3d)+"%";}}}function preloadImages(){var _3f=document.createElement("div");_3f.id="preloader";document.body.appendChild(_3f);}function submitForm(_40){iui.showPageByHref(_40.action||"POST",encodeForm(_40),_40.method);}function encodeForm(_41){function encode(_42){for(var i=0;i<_42.length;++i){if(_42[i].name){args.push(_42[i].name+"="+escape(_42[i].value));}}}var _44=[];encode(_41.getElementsByTagName("input"));encode(_41.getElementsByTagName("textarea"));encode(_41.getElementsByTagName("select"));return _44;}function findParent(_45,_46){while(_45&&(_45.nodeType!=1||_45.localName.toLowerCase()!=_46)){_45=_45.parentNode;}return _45;}function hasClass(_47,_48){var re=new RegExp("(^|\\s)"+_48+"($|\\s)");return re.exec(_47.getAttribute("class"))!=null;}function replaceElementWithSource(_4a,_4b){var _4c=_4a.parentNode;var _4d=_4a;while(_4c.parentNode!=document.body){_4c=_4c.parentNode;_4d=_4d.parentNode;}var _4e=document.createElement(_4d.localName);_4e.innerHTML=_4b;_4c.removeChild(_4d);while(_4e.firstChild){_4c.appendChild(_4e.firstChild);}}function $(id){return document.getElementById(id);}function ddd(){console.log.apply(console,arguments);}})();
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
163:
164:
165:
166:
167:
168:
169:
170:
171:
172:
173:
174:
175:
176:
177:
178:
179:
180:
181:
182:
183:
184:
185:
186:
187:
188:
189:
190:
191:
192:
193:
194:
195:
196:
197:
198:
199:
200:
201:
202:
203:
204:
205:
206:
207:
208:
209:
210:
211:
212:
213:
214:
215:
216:
217:
218:
219:
220:
221:
222:
223:
224:
225:
226:
227:
228:
229:
230:
231:
232:
233:
234:
235:
236:
237:
238:
239:
240:
241:
242:
243:
244:
245:
246:
247:
248:
249:
250:
251:
252:
253:
254:
255:
256:
257:
258:
259:
260:
261:
262:
263:
264:
265:
266:
267:
268:
269:
270:
271:
272:
273:
274:
275:
276:
277:
278:
279:
280:
281:
282:
283:
284:
285:
286:
287:
288:
289:
290:
291:
292:
293:
294:
295:
296:
297:
298:
299:
300:
301:
302:
303:
304:
305:
306:
307:
308:
309:
310:
311:
312:
313:
314:
315:
316:
317:
318:
319:
320:
321:
322:
323:
324:
325:
326:
327:
328:
329:
330:
331:
332:
333:
334:
335:
336:
337:
338:
339:
340:
341:
342:
343:
344:
345:
346:
347:
348:
349:
350:
351:
352:
353:
354:
355:
356:
357:
358:
359:
360:
361:
362:
363:
364:
365:
366:
367:
368:
369:
370:
371:
372:
373:
374:
375:
376:
377:
378:
379:
380:
381:
382:
383:
384:
385:
386:
387:
388:
389:
390:
391:
392:
393:
394:
395:
396:
397:
398:
399:
400:
401:
402:
403:
404:
405:
406:
407:
408:
409:
410:
411:
412:
413:
414:
415:
416:
417:
418:
419:
420:
421:
422:
423:
424:
425:
426:
427:
428:
429:
430:
431:
432:
433:
434:
435:
436:
437:
438:
439:
440:
441:
442:
443:
444:
445:
446:
447:
448:
449:
450:
451:
452:
453:
454:
455:
456:
457:
458:
459:
460:
461:
462:
463:
464:
465:
466:
467:
468:
469:
470:
471:
472:
473:
474:
475:

Select allOpen in new window

 

by: mkosbiePosted on 2009-05-04 at 09:51:56ID: 24296888

It's an iPhone UI conflict.  You're linking to #displayCamera like you're supposed to, but you've then id'ed the div as "#displayCamera".  It should be "displayCamera" (w/out the # first).  I copied the code of your test site, made a couple of changes to insert what you have here, and have am posting a complete version.  Seems to work fine to me.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>TRIMARC</title>
<meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;"/>
<link rel="apple-touch-icon" href="./trimarc.png" />
<meta name="apple-touch-fullscreen" content="YES" />
<style type="text/css" media="screen">@import "./lib/iui/iui.css";</style>
<script type="application/x-javascript" src="./lib/iui/iui.js"></script>
<script type="text/javascript">
function setCamera(wci, mm) {
    var imgCamera = document.getElementById("imgCamera");
    var mmText = document.getElementById("txtMM");
 
    imgCamera.src = wci;
    mmText.innerHTML = mm;
}
</script>
</head>
<body>
    <!-- Top toolbar -->
 
	<div class="toolbar">
        <h1 id="pageTitle"></h1>
        <a id="backButton" class="button" href="#"></a>
		<a class="button" href="#mainMenu">Home</a>
    </div>
    
	<!-- Main Menu -->
    <ul id="mainMenu" title="Main Menu" selected="true">
		<li><a href="#cameras">Traffic Cameras</a></li>
 
		<li><a href="#incidents">Incident Reports</a></li>
		<li><a href="#about">About</a></li>
    </ul>
	
	<!-- Traffic Cameras-->
	<ul id="cameras" title="Traffic Cameras">
		<li><a href="#i64">I-64</a></li>
		<li><a href="#i65">I-65</a></li>
 
		<li><a href="#i71">I-71</a></li>
		<li><a href="#i264">I-264</a></li>
		<li><a href="#i265">I-265</a></li>
		<li><a href="#downtown">Downtown</a></li>
	</ul>
	
	<!-- I-64 -->
	<ul id="i64" title="I-64">
 
		<li class="group">High Traffic Areas</li>
		<li><a href="#displayCamera" onclick="setCamera('http://trimarc.org/images/snapshots/CCTV020.jpg','mm');">22nd St.</a></li>
		<li><a href="#i64_grinstead">Grinstead Dr.</a></li>
		<li><a href="#i64_ofr">Oxmoor Farm Rd.</a></li>
		<li class="group">Intersections</li>
		<li><a href="#i64_i264">I-264</a></li>
 
		<li><a href="#i64_i265">I-265</a></li>
	</ul>
	
	<!-- I-65 -->
	<ul id="i65" title="I-65">
		<li class="group">High Traffic Areas</li>
		<li><a href="#i65_arthur">Arthur St.</a></li>
		<li><a href="#i65_fernvalley">Fern Valley Rd.</a></li>
 
		<li><a href="#i65_grade">Grade Ln.</a></li>
		<li><a href="#i65_hc">Hospital Curve</a></li>
		<li><a href="#i65_outerloop">Outer Loop</a></li>
		<li class="group">Intersections</li>
		<li><a href="#i65_i264">I-264</a></li>
		<li><a href="#i65_i265">I-265</a></li>
 
		<li><a href="#i65_sg">Spaghetti Junction</a></li>
	</ul>
	<!-- I-71 -->
	<ul id="i71" title="I-71">
		<li class="group">High Traffic Areas</li>
		<li><a href="#i71_adams">Adams St.</a></li>
		<li><a href="#i71_frankfort">Frankfort Ave.</a></li>
 
		<li><a href="#i71_zorn">Zorn Ave.</a>
		<li class="group">Intersections</li>
		<li><a href="#i71_i264">I-264</a></li>
		<li><a href="#i71_i265">I-265</a></li>
	</ul>
	<!-- I-264 -->
		<ul id="i264" title="I-264">
 
			<li><a href="i264_crums">Crums Ln.</a></li>
			<li><a href="i264_dixie">Dixie Hwy.</a></li>
			<li><a href="i264_freedom">Freedom Way</a></li>
			<li><a href="i264_newburg">Newburg Rd.</a></li>
			<li><a href="i264_poplar">Poplar Level</a></li>
			<li><a href="i264_river">River Park Dr.</a></li>
 
			<li><a href="i264_taylor">Taylor Blvd.</a></li>
			<li><a href="i264_westport">Westport Rd.</a></li>
			<li></li>
		<li class="group">High Traffic Areas</li>
		<li class="group">Intersections</li>
			<li><a href="i264_i71">I-71</a></li>
 
	</ul>
	<!-- I-265 -->
		<ul id="i265" title="I-265">
		<li class="group">High Traffic Areas</li>
		<li class="group">Intersections</li>
	</ul>
	<!-- Downtown -->
	
	
	<!-- Camera Page -->
 
	<div id="displayCamera" title="" class="panel">
		<img id="imgCamera" src="" width="300" height="225" align="center"><br /><br />
		<h2>More Information</h2>
		<fieldset>
			<div class="row">
				<label>Mile Marker: <span id="txtMM">18.6</span></label>
			</div>
			<div class="row">
 
				<label>CCTV No.: 045</label>
			</div>
		</fieldset>
	</div>
</body>
</html>

                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:

Select allOpen in new window

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...