Jump to content

while loop that has the browser move to a certain part...


thewooleymammoth

Recommended Posts

kinda hard to explain what im looking for

 

so far i have a loop

 


while ($num < 1000)
{
if ($condition == $rightcondition)
{

echo "need page to focus here on load<br>";
}
else {
echo "other text<br>";
}

 

can anyone tell me the html that would do that? perhaps some sortof of <pagefocus> </pagefocus>????

Link to comment
Share on other sites

Javascript it is. HTML doesn't have logic based commands, meaning you can't use if/else or while statements in it. It also doesn't have any focus commands, or really any interactivity at all, it's purely for content. Or should be - some people use it wrong and build markup into their html. But that's a side point.

Link to comment
Share on other sites

Give the input an id:

 

<input type="text" id="target" name="name" />

 

Then you can use this javascript in the head of your document:

 

<script type="text/javascript">
window.onload = function()
{
  document.getElementById("target").focus
}
</script>

 

If that doesn't work, then post the relevant code.

Link to comment
Share on other sites

its not a feild i want to focus on its an image that i would like to appear at the top of the screen, so should i use

 

<img src='whatever.jpg' id='target'><br>

 

or should i use a hidden field type? the relevant code is a page with 147 lines but ill write a more detailed code

 




foreach ($list_of_images as $image)
{
$selectimage=$_GET['image'];
if ($image == $selectimage)
{
//i want the the page to automatically load with this at the top of the screen becuase there could potentially be a huge list of images and scrolling down each time gets annoying
echo " <img src='$image'><br>need page to focus here on load<br>";
}
else {
echo "<a href='image.php?image='$image'>other image titles<br>";
}
}

 

here is an example page

 

http://fatalinjury.org/vf.php?name=5wooley4@gmail.com

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.