0

I'm trying to create a javascript that takes an input location of a target .html document and displays it in a frame, at the same time it also calls a file in the same folder with a different name to display it to another frame.

My problem starts here since i have multiple folders to which i want to do that to.

How the folders look like ^^ each folder has 2 files which i'm trying to link


This is the error I get:

enter image description here


Code:

<head>
  <meta charset="UTF-8">
  <link rel="stylesheet" type="text/css" href="Unistyle.css">
  
  <script>
   function CallSite(Plocation)
   {
    parent.MainBody.location=Plocation;
    parent.Opis.location=Plocation/opis.html;
   }
  </script>
  
 </head>
 <body id="globalBG">
  <h1><b>Kazalo</b></h1>
  <div style="padding-top:1px;padding-bottom:1px;color:aliceblue;background-color:#201010">  
   <ol>
   <li><a href="javascript:CallSite('pages/1/1stran.html')" target="MainBody">Naloga</a></li>
   <li><a href="javascript:CallSite('pages/2/drzave.html')" target="MainBody">Naloga</a></li>
   </ol>
  </div>
 </body>
</HTML>

I do know hat the 2nd part of the function to which i call the opis.html file is wrong, however i have no idea how to correctly write that piece of code

Orlando Herrera
  • 3,481
  • 1
  • 34
  • 44
  • You need string concatenation here: `parent.Opis.location=Plocation/opis.html`. – Teemu Dec 27 '16 at 15:54
  • That fixed the problem! thanks for that. However now i get: 'GET file:///H:/TestY/undefinedopis.html net::ERR_FILE_NOT_FOUND' I can do a workaround that but i'd very much like to know why it changes the location to undefined. This is what i did: 'parent.Opis.location=Plocation.parent+"opis.html";' –  Dec 27 '16 at 17:03
  • The dash is missing ... Also, you can't refer files in user's machine via a web page. Aand there's not code enough for us to determine values for `parent.MainBody`, `parent.Opis`, `Plocation` etc. – Teemu Dec 27 '16 at 17:06
  • [Index folder](http://imgur.com/wzadoI5) I'm using to create frames and set their names. Then i use Kaza.html to target 2 frames, 1 of them being MainBody, the other one Opis. In the Pages folder are the folders marked from 1 to 8 which have 2 files in them, 1 of them always being "opis.html" [example](http://imgur.com/JElybpl) –  Dec 27 '16 at 17:20
  • Hmm... Use `top` to refer the frameset page. Also, it looks like `Plocation` is not passed when the function was called, or you've passed something which has value `undefined`. This [answer](http://stackoverflow.com/questions/24074694/get-element-value-inside-iframe-which-is-nested-inside-frame-in-javascript/24096958#24096958) might also shed some light to inter-frame references. – Teemu Dec 27 '16 at 17:28
  • Well this is the workaround i did: [code](http://imgur.com/jjjqeHc) [page](http://imgur.com/a/D8PbK) –  Dec 27 '16 at 17:48

0 Answers0