<a href.external javascript function

  • rpoland
  • Born
  • Born
  • rpoland
  • Posts: 4
  • Loc: Fort collins, CO

Post 3+ Months Ago

In an effort to make the page work with Safari, Firefox and IE I have been trying two solutions.

Help would be appreciated,

1. Move the function to a separate .js file. This seems to be the best approach but either the .js has an error or I don't know how to call it.

One version of code and .js below.

2. Using "if" and "if" "else". So far I haven't been able to find one of these that will separate Safari, IE, Firefox, etc.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-Transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<title>Test File</title>
<script type="text/javascript" src="loadlargeview.js"></script>
<link href="loadlargeviewcopy.js" rel="javascript" type="text/javascript" />
<link href="index.css" rel="stylesheet" type="text/css" />
</head>
<body>
<table align="center" width="650">
<tr>
<td>
<center>
<a href="loadLargeViewcopy.js('images/irisflower.jpg','Large View', 650, 848, 500, 500)">
<img src="images/irisflower_small.jpg" alt="image" width="160" height="209" align="bottom" />
                         <br />
<strong>Large View</strong>
</a>
</center>
</td>
</tr>
</table>
</body>
</html>

****

//   function loadLargeView by Richard A. Hyman;  www.rhyman.net
//   copyright© R.A.Hyman,all rights reserved.
//   for use,contact R.Hyman via email at "rick @t rhyman.net"
var largeURL;
var theWinTitle;
var imageWidth;
var imageHeight;
var windowWidth;
var windowHeight;
var imageRatio= imageWidth/imageHeight;
var scriptStr = '\r window.onresize=resizeMyImage;';
var loadedWin = window.open('','','location=0,height='+windowHeight+',width='+windowWidth+',scrollbars=0,resizable=1');
loadedWin.document.write('<html><head><title>'+theWinTitle+'</title>');
loadedWin.document.write('\r<script language=\"javascript1.2\">');
loadedWin.document.write('\r function resizeMyImage() {');
loadedWin.document.write('\r var imageRatio=' + imageRatio+ ';');
loadedWin.document.write('\r var newWinWidth=window.innerWidth; var newWinHeight=window.innerHeight; var windowRatio= newWinWidth/newWinHeight;');
loadedWin.document.write('\r if(windowRatio > imageRatio) {document.main_image.height = newWinHeight; document.main_image.width = newWinHeight * imageRatio;} else {document.main_image.width = newWinWidth; document.main_image.height = newWinWidth / imageRatio}');
loadedWin.document.write('\r }');
loadedWin.document.write(scriptStr);
loadedWin.document.write('\r</script></head><body topmargin=0 leftmargin=0 marginheight=0 marginwidth=0>');
loadedWin.document.write('<img src='+largeURL+' name=\"main_image\">');
loadedWin.document.write('</body></html>');
var loadedWinRatio = windowWidth/windowHeight;
if(loadedWinRatio > imageRatio) {
loadedWin.document.main_image.height= windowHeight;
loadedWin.document.main_image.width= windowHeight*imageRatio;
} else {
loadedWin.document.main_image.width= windowWidth;
loadedWin.document.main_image.height= windowWidth/imageRatio;
}
//  end of loadLargeView
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8398
  • Loc: USA

Post 3+ Months Ago

It seems like you are trying to implement one HTML document into each other. What I mean to say is that the Javascript file already describes the html codes that you have on your site. Try the following code

Code: [ Select ]
<link href="loadlargeviewcopy.js" rel="javascript" type="text/javascript" />


Put that in your main document (be sure to save a back-up.

Although, I don't think that would work. You would probably need to cut that javascript files into two. One that goes for header and the other that goes for body without those html codes in it.
  • rpoland
  • Born
  • Born
  • rpoland
  • Posts: 4
  • Loc: Fort collins, CO

Post 3+ Months Ago

Thanks Bogey,

Found the cure.

Seems that the Function needs to be in a .js file instead of as a file of it's own.

referenced by:
<script type="text/javascript" src="../indexPage.js"></script>

and called by:
<a href="javascript:loadLargeView('... >
<strong>Large View</strong></a>
  • rpoland
  • Born
  • Born
  • rpoland
  • Posts: 4
  • Loc: Fort collins, CO

Post 3+ Months Ago

After all these years the cure is no longer working.
WEBSITE: f o r t m a c org/index.html
These commands only work on Google Chrome and none of the other browsers that I have.

Any suggestions?

TIA,
  • Bogey
  • Genius
  • Genius
  • Bogey
  • Posts: 8398
  • Loc: USA

Post 3+ Months Ago

Did you do anything to any of your files or changed anything before you noticed that it stopped working?

I checked the source of index.js and the index.html and couldn't see anything that would cause it to break...
  • rpoland
  • Born
  • Born
  • rpoland
  • Posts: 4
  • Loc: Fort collins, CO

Post 3+ Months Ago

Don't know when it broke. Didn't see a need to constantly monitor various functions. I did replace the code (newer version) in index.js AFTER I saw the problem. I'm sure that most, if not all, versions in the browsers have updated several times. Probably update OS a few times too, OS 10.7.3.

Safari - broke
Firefox - version 11 - broke
Opera - version 11.61 - broke
Camino - version 2.1.2 (1.9.2.28 20120308211433) - broke
Google Chrome - version 17.0.963.79 - WORKS

Post Information

  • Total Posts in this topic: 6 posts
  • Users browsing this forum: No registered users and 63 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.