Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update/Refresh Embed/Object Content 1

Status
Not open for further replies.

asdf5678

IS-IT--Management
Dec 1, 2006
5
US
I have an embedded pdf:

<embed src="images/Picture1.pdf" type="application/pdf" name="slide" width="1012" height="700"></embed>

I execute:

document.slide.src = myPix[thisPic];

The good news is that a javascript alert will confirm that document.slide.src has been changed to a different pdf.

The bad news is that the new pdf is not shown on the screen. The original pdf remains, despite changing the embed src.

Can the embedded content be updated on-screen?
 
Does anyone know something about it? I don't think it's too ambiguous a question, but even cofirmation of no solution would be helpful. Thanks to those who read it. Extra thanks for replying.
 
I'm not sure you can just replace the information of the src attribute to get the embed to fire off again. I'd suggest altering your code to have the Javascript replace the entire embed tag dynamically. This should allow you to replace the PDF on the fly as you're looking to do.

- George
 
Thanks, George!

I looked into replacing the entire embed tag dynamically, but my attempt did not solve the problem. I used:

document.contextual(document.tags.EMBED).refresh;

I received an error that document.tags.EMBED was null or not an object. I got the same error for document.tags.A.

Any further suggestions?
 
If you had the pdf in an iframe, you could easily use normal links to switch the pdfs. It would even be more accessible that way.
 
I'm working with your suggestion, Vragabond.

I've gotten all of the iframe, target stuff written into the code, but I have another hurdle: the links are to pdfs listed in a javascript array. Is there a way to assign a javascript array item (a pdf in this case) to an anchor tag?

This is what I have:
<script language="JavaScript" type="text/javascript">

myPix = new Array("images/Picture1.pdf","images/Picture2.pdf","images/Picture3.pdf","images/Picture4.pdf","images/Picture5.pdf","images/Picture6.pdf","images/Picture7.pdf","images/Picture8.pdf","images/Picture9.pdf","images/Picture10.pdf","images/Picture11.pdf","images/Picture12.pdf","images/Picture13.pdf","images/Picture14.pdf","images/Picture15.pdf");

thisPic = 0;

document.write('<a target="slide" href=myPix[thisPic]></a>');
-(should) put the next slide/arrayelement on screen

</script>

<iframe src="images/Picture1.pdf" type="application/pdf" name="slide" width="1012" height="700">

Thanks in advance!
 
First, there is no type attribute for the iframe. Is it some kind of dynamic process that creates that javascript array of items or is it that someone just put it in html like that. If it is the former, you just need to iterate through the array (ask in forum216 about that) and if it is the latter, you should simply rewrite the code so that it is plain links. No need to exclude people with JS turned off because of sloppy coding.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top